pycharm运行错误如何解决?
AttributeError: 'RepeatedCompositeFieldContainer' object has no attribute 'append'
在pycharm中导入tensorflow模块,测试GradientTape函数
相关代码
import tensorflow as tf
with tf.GradientTape() as tape:
x = tf.Variable(tf.constant(3.0))
y = tf.pow(x, 2)
grad = tape.gradient(y, x)
print(grad)
出现如下错误
Traceback (most recent call last):
File "E:/MOOCTF2.1/class1/p34_GradientTape.py", line 4, in <module>
x = tf.Variable(tf.constant(3.0))
File "G:PYTHONlibsite-packagestensorflowpythonopsvariables.py", line 261, in call
return cls._variable_v2_call(*args, **kwargs)
File "G:PYTHONlibsite-packagestensorflowpythonopsvariables.py", line 255, in _variable_v2_call
shape=shape)
File "G:PYTHONlibsite-packagestensorflowpythonopsvariables.py", line 236, in <lambda>
previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
File "G:PYTHONlibsite-packagestensorflowpythonopsvariable_scope.py", line 2647, in default_variable_creator_v2
shape=shape)
File "G:PYTHONlibsite-packagestensorflowpythonopsvariables.py", line 263, in call
return super(VariableMetaclass, cls).__call__(*args, **kwargs)
File "G:PYTHONlibsite-packagestensorflowpythonopsresource_variable_ops.py", line 1434, in init
distribute_strategy=distribute_strategy)
File "G:PYTHONlibsite-packagestensorflowpythonopsresource_variable_ops.py", line 1582, in _init_from_args
graph_mode=self._in_graph_mode)
File "G:PYTHONlibsite-packagestensorflowpythonopsresource_variable_ops.py", line 243, in eager_safe_variable_handle
shape, dtype, shared_name, name, graph_mode, initial_value)
File "G:PYTHONlibsite-packagestensorflowpythonopsresource_variable_ops.py", line 179, in _variable_handle_from_shape_and_dtype
handle_data.shape_and_type.append(
AttributeError: 'RepeatedCompositeFieldContainer' object has no attribute 'append'
Process finished with exit code 1
百度几乎没有类似问题,请教各位大佬,这是怎么回事,应该如何解决呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论