问答

pycharm运行错误如何解决?

作者:admin 2021-08-04 我要评论

AttributeError: 'RepeatedCompositeFieldContainer' object has no attribute 'append' 在pycharm中导入tensorflow模块,测试GradientTape函数 相关代码 import...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

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

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • pycharm运行错误如何解决?

    pycharm运行错误如何解决?

  • 只有一个手机可以使用charles抓取https

    只有一个手机可以使用charles抓取https

  • vue中的watch如何观测一个自己添加的属

    vue中的watch如何观测一个自己添加的属

  • 两个以上列表合并到一个列表,python可

    两个以上列表合并到一个列表,python可

腾讯云代理商
海外云服务器