Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

TypeError: __init__() got an unexpected keyword argument 'error_clipping_threshold' in fc_layer

Open dockiHan opened this issue 8 years ago • 7 comments

paddlepaddle版本v0.10.0(大概10月份的docker镜像) mixed_layer 可以正常使用error_clipping_threshold, 在fc_layer就会报如下错误:

I1207 07:43:08.559044    35 Util.cpp:166] commandline:  --log_error_clipping=True --use_gpu=False --trainer_count=1 
Traceback (most recent call last):
  File "start_trainer.py", line 678, in <module>
    main(args)
  File "start_trainer.py", line 604, in main
    gradient_clipping_threshold=args.gradient_clipping_threshold)
  File "/usr/local/lib/python2.7/dist-packages/Newbie-0.0.1-py2.7.egg/newbie/model/anomaly_detection/lstm_model.py", line 137, in __init__
    self.__lstm_network()
  File "/usr/local/lib/python2.7/dist-packages/Newbie-0.0.1-py2.7.egg/newbie/model/anomaly_detection/lstm_model.py", line 229, in __lstm_network
    self.__parameters = paddle.parameters.create(cost)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/parameters.py", line 19, in create
    topology = Topology(layers)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/topology.py", line 69, in __init__
    layers, extra_layers=extra_layers)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/layer.py", line 96, in parse_network
    return __parse__(__real_func__)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/config_parser_utils.py", line 32, in parse_network_config
    config = config_parser.parse_config(network_conf, config_arg_str)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer/config_parser.py", line 3597, in parse_config
    trainer_config()
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/layer.py", line 89, in __real_func__
    real_output = [each.to_proto(context=context) for each in output_layers]
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 109, in to_proto
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 116, in to_proto
    ret_val = self.to_proto_impl(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/v2/config_base.py", line 212, in to_proto_impl
    return getattr(conf_helps, method_name)(**args)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in __wrapper__
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in __wrapper__
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in __wrapper__
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/default_decorators.py", line 53, in __wrapper__
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/layers.py", line 329, in wrapper
    return method(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer_config_helpers/layers.py", line 938, in fc_layer
    **ExtraLayerAttribute.to_kwargs(layer_attr))
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer/config_parser.py", line 3180, in Layer
    return layer_func(name, **xargs)
  File "/usr/local/lib/python2.7/dist-packages/paddle/trainer/config_parser.py", line 1592, in __init__
    super(FCLayer, self).__init__(name, 'fc', size, inputs=inputs, **xargs)
TypeError: __init__() got an unexpected keyword argument 'error_clipping_threshold'

我的使用方式:

fc_attr = paddle.attr.ExtraAttr(error_clipping_threshold=self.__error_clipping_threshold,
 drop_rate=self.__drop_rate)

fc_0 = paddle.layer.fc(input=X, 
                       size=self.__hidden_dim, 
                       act=paddle.activation.Linear(), 
                       param_attr=fc_para_attr_first, 
                       layer_attr=fc_attr)

dockiHan avatar Dec 07 '17 07:12 dockiHan

你好,当前的paddlepaddle版本是可以使用的,可以更新一下试试

peterzhang2029 avatar Dec 07 '17 08:12 peterzhang2029

@peterzhang2029 你好,请问你指的当前版本是develop版本还是最近的0.10.0版本?我看官方文档上develop版已经更改了一些API接口,我怕换成develop版代码又要大改动

dockiHan avatar Dec 07 '17 08:12 dockiHan

我用的develop版本测试的。

peterzhang2029 avatar Dec 07 '17 08:12 peterzhang2029

@dockiHan 你好,error_clipping_threshold这个参数不应该从paddle.init()传递,而是需要逐层设置,有另一个梯度截断的全局参数gradient_clipping_threshold可以在初始化optimizer的时候传递。

kuke avatar Dec 07 '17 09:12 kuke

@kuke 你好,我并不是从paddle.init()传递的,请看我上面的使用方式,我使用paddle.attr.ExtraAttr将 error_clipping_threshold传入fc_layer的。 可能因为版本的问题吗?

dockiHan avatar Dec 08 '17 07:12 dockiHan

@dockiHan 你好,你的使用方式应该是没有问题的,我用最新的docker镜像在fc层上加error_clipping_threshold 是没有问题的,可能是后续有fix这个问题。

peterzhang2029 avatar Dec 12 '17 03:12 peterzhang2029

Closing due to low activity. Feel free to reopen it.

peterzhang2029 avatar Dec 30 '17 13:12 peterzhang2029