waq127520 2020-04-10 20:56 采纳率: 0%
浏览 3756

module 'tensorflow' has no attribute 'variable'

用pip装的tensorflow1.14.0,创建变量时报错:

import tensorflow as tf
input=tf.variable(tf.random_normal([2,3,3,5]))

报错内容为:
Traceback (most recent call last):
  File "E:/HelloWorld/AI/CV/project/exam.py", line 28, in <module>
    input=tf.variable(tf.random_normal([2,3,3,5]))
  File "E:\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation_wrapper.py", line 106, in __getattr__
    attr = getattr(self._dw_wrapped_module, name)
AttributeError: module 'tensorflow' has no attribute 'variable'

在网上找了好多种办法(卸了管理员模式重装,换个版本)都没有用。恳求大神帮忙解惑。
我的python是3.7.4的,但是activate tensorflow之后python是3.7.7的,不知道跟这个有没有关系。

  • 写回答

1条回答 默认 最新

  • 周周周睿 2020-05-26 11:26
    关注

    tf.Variable(),大写V

    评论

报告相同问题?