Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

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
百度几乎没有类似问题,请教各位大佬,这是怎么回事,应该如何解决呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...