AttributeError: can‘t set attribute

Traceback (most recent call last):
  File "D:/master/Multi-level-DCNet-master/3leveldcnet.py", line 342, in <module>
    routings=args.routings)
  File "D:/master/Multi-level-DCNet-master/3leveldcnet.py", line 60, in MultiLevelDCNet
    conv, nb_filter = densenet.DenseBlock(x, growth_rate=32, nb_layers=8, nb_filter=32)
  File "D:\master\Multi-level-DCNet-master\densenet.py", line 64, in DenseBlock
    cb = __conv_block(x, growth_rate, bottleneck, dropout_rate, weight_decay)
  File "D:\master\Multi-level-DCNet-master\densenet.py", line 27, in __conv_block
    x = BatchNormalization(axis=concat_axis, epsilon=1.1e-5)(ip)
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 575, in __call__
    self.build(input_shapes[0])
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\keras\layers\normalization.py", line 103, in build
    constraint=self.gamma_constraint)
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py", line 87, in wrapper
    return func(*args, **kwargs)
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 399, in add_weight
    constraint=constraint)
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 323, in variable
    v.constraint = constraint
AttributeError: can't set attribute

修改代码中的部分:

v = tf.Variable(value, dtype=_convert_string_dtype(dtype), name=name)
    if isinstance(value, np.ndarray):
        v._keras_shape = value.shape
    elif hasattr(value, 'get_shape'):
        v._keras_shape = int_shape(value)
    v._uses_learning_phase = False
    # TODO: move to `tf.get_variable` when supported in public release.
    v.constraint = constraint  #修改为 v._constraint = constraint
    return v

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值