浅谈Tensorflow由于版本问题出现的几种错误及解决方法

yipeiwu_com6年前Python基础

1、AttributeError: 'module' object has no attribute 'rnn_cell'

S:将tf.nn.rnn_cell替换为tf.contrib.rnn

2、TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

S:由于tf.concat的问题,将tf.concat(1, [conv1, conv2]) 的格式替换为tf.concat( [conv1, conv2],1)

3、AttributeError: 'module' object has no attribute 'pack'

S:将pack替换为stack

4、ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)

S:按照提示,需要将括号内的形参写出,即(logits=pre, lables=tru)而非(pre,tru)

5、ValueError: Variable Wemb/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

S:需要定义scope,虽然报错可能是在optimizer处提示,但需要在定义模型时增加scope,即

with tf.variable_scope(tf.get_variable_scope()) as scope:
# model construction

以上这篇浅谈Tensorflow由于版本问题出现的几种错误及解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python实现移位加密和解密

python实现移位加密和解密

本文实例为大家分享了python实现移位加密和解密的具体代码,供大家参考,具体内容如下 代码很简单,就不多做解释啦。主要思路是将字符串转为Ascii码,将大小写字母分别移位密钥表示的位...

pandas获取groupby分组里最大值所在的行方法

pandas获取groupby分组里最大值所在的行方法 如下面这个DataFrame,按照Mt分组,取出Count最大的那行 import pandas as pd df = pd....

python统计字符串中指定字符出现次数的方法

本文实例讲述了python统计字符串中指定字符出现次数的方法。分享给大家供大家参考。具体如下: python统计字符串中指定字符出现的次数,例如想统计字符串中空格的数量 s = "C...

用Python的Flask框架结合MySQL写一个内存监控程序

用Python的Flask框架结合MySQL写一个内存监控程序

这里以监控内存使用率为例,写的一个简单demo性程序,具体操作根据51reboot提供的教程写如下。 一、建库建表 创建falcon数据库: mysql> create dat...

Python 限制线程的最大数量的方法(Semaphore)

如下所示: import threading import time sem=threading.Semaphore(4) #限制线程的最大数量为4个 def gothrea...