tensorflow使用中的坑:module'tensorflow'has no attribute 'sub'

来源:互联网 发布:ubuntu使用管理员账户 编辑:程序博客网 时间:2024/06/06 18:34

        问题描述:定义了一个Variable x并进行了初始化,又定义了一个constant a,二者是同型矩阵,输入语句sub=tf.sub(x,a)定义一个op,编译器报错:module'tensorflow'has no attribute 'sub'

        问题原因:TensorFlow 发布的新版本对之前的API 进行了修改:tf.mul, tf.sub and tf.neg are deprecated in favor of tf.multiply, tf.subtract and tf.negative.


        解决方法:使用时将 tf.mul 改成 tf.multiply 即可另外 tf.sub 和 tf.neg 也要相应修改为 tf.subtract 和 tf.negative。
阅读全文
0 0
原创粉丝点击