How to set L1 weight decay?
- global setting(...) function call has no L1 weight decay setting, so, how to set L1 weight decay?
- can set different L1 weight decay for different inputs of same layer in model config file?
L1 example:
data = data_layer(name="feature", size=feature_dict_size)
hidden1 = fc_layer(name="hidden1",
input=data,
size=8,
param_attr=ParameterAttribute(l1_rate=0.1,
sparse_update=True))
L2 example:
settings(
batch_size=batch_size,
learning_rate=0.1,
learning_method=RMSPropOptimizer(),
regularization=L2Regularization(1.0),
)
set L1 with parameter level, while you can set L2 with global and parameter level.
@reyoung @emailweixu Maybe we need to unifiy L1 and L2 to get more user-friendly API.
Should add L1Regularization() for settings(). In fact, the effect of L2Regularization() is to have a default l2_rate for each parameter.
@emailweixu I will follow it.
- add L1Regularization()
- more detailed doc about decay rate
In addition, for pure dense local updater, L1 is not supported in SgdLocalUpdater. @emailweixu pls give some more comments on it if feel free.
@backyes Is this issue should associate to some milestone? Should we support it in 2 weeks or 4 weeks?
@reyoung L1 正则为啥本地训练不能用啊?这样会影响训练出的模型的效果。 l1正则 和 sparse_update 都能支持一下local 训练的模式吗?
@buptzzl Hello, @backyes is working on this issue. Please ask him for progress or just subscribe this issue.
For local mode, if the layer set with sparse_update=true, the L1 indeed works.
data = data_layer(name="feature", size=feature_dict_size)
hidden1 = fc_layer(name="hidden1",
input=data,
size=8,
act=LinearActivation(),
param_attr=ParameterAttribute(l1_rate=1, sparse_update=True))
That works well. @buptzzl
You can paste your model if you feel free.
@backyes 我尝试了一下,仍然失败了。 网络配置: fea_list = [] for i, sz in enumerate(fea_size): fea_list.append(data_layer(name="slot%d" % i, size=sz)) label_size = 2 hidden1 = fc_layer(input=fea_list, size=64, act=TanhActivation(), param_attr=ParameterAttribute(l2_rate=0.0002, initial_min=0.0, initial_max=1e-6, sparse_update=True, l1_rate=0.1)) output = fc_layer(input=hidden1, size=label_size, act=SoftmaxActivation(), param_attr=ParameterAttribute(l2_rate=0.002, initial_min=0.0, initial_max=1e-6))
失败信息 Failed Info:
Traceback (most recent call last):
File "/home/work/.jumbo/lib/python2.7/site-packages/paddle-0.8.0b0-py2.7.egg/paddle/trainer/config_parser.py", line 3113, in parse_config_and_serialize
config = parse_config(config_file, config_arg_str)
File "/home/work/.jumbo/lib/python2.7/site-packages/paddle-0.8.0b0-py2.7.egg/paddle/trainer/config_parser.py", line 3089, in parse_config
execfile(config_file, make_config_environment(config_file, config_args))
File "trainer_conf.fsg_1k.py", line 43, in
The L1 weight decay can be set in ParameterAttribute: https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/trainer_config_helpers/attrs.py#L146 . Close this issue. If any questions, we will fix it in the new issue.