浅谈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调用服务接口的实例

如下所示: #! /usr/bin/env python # coding=utf-8 ###############################################...

Python3实现生成随机密码的方法

本文实例讲述了Python3实现生成随机密码的方法,在Python程序设计中有着广泛的实用价值。具体方法如下: 本文实例主要实现创建8位随机密码(大小写字母+数字),采用Python3生...

python处理“&#”开头加数字的html字符方法

python处理“&#”开头加数字的html字符方法

python如何处理“&#”开头加数字的html字符,比如:风水这类数据。 用python抓取数据时,有时会遇到想要数据是以“&#”开头加数字的字符,比如图中...

python的else子句使用指南

在日常coding中,分支语句的使用非常普遍,经常会根据是否满足一定的条件对代码执行的逻辑进行一些控制,所以大家对if[elif[else]]一定不会陌生。分支语句中的else子句在其它...

Python获取Windows或Linux主机名称通用函数分享

通过python的os模块获取windows或者linux主机名的通用函数。 复制代码 代码如下: #!/usr/bin/env python  #coding=utf-8&...