错误TypeError: add_weight() got multiple values for argument ‘name‘

错误TypeError: add_weight() got multiple values for argument ‘name’

在代码执行时报错TypeError: add_weight() got multiple values for argument ‘name’。经过查阅资料发现是在定义卷积模型的代码模块中的

self.add_weight(shape,
				initializer=self.gamma_init,
				regularizer=self.gamma_regularizer,
				name='{}_gamma'.format(self.name),
				trainable=False)

应该为

self.add_weight(shape=shape,
				initializer=self.gamma_init,
				regularizer=self.gamma_regularizer,
				name='{}_gamma'.format(self.name),
				trainable=False)

指定shape=shape,就可以解决这个问题。

猜你喜欢

转载自blog.csdn.net/weixin_41963310/article/details/109424890