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

yipeiwu_com5年前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科学计算之narray对象用法

python科学计算之narray对象用法

写在前面 最近在系统的看一些python科学计算开源包的内容,虽然以前是知道一些的,但都属于零零碎碎的,希望这次能把常用的一些函数、注意项整理下。小白的一些废话,高手请略过^ _ ^。文...

python访问sqlserver示例

最近遇到了Python访问SqlServer的问题,这里总结下。 一、Windows下配置Python访问Sqlserver 环境:Windows 7 + Sqlserver 2008...

django数据模型(Model)的字段类型解析

字段类型(Field types) 1、AutoField 它是一个根据 ID 自增长的 IntegerField 字段。通常,你不必直接使用该字段。如果你没在别的字段上指定主 键,Dj...

Python用sndhdr模块识别音频格式详解

本文主要介绍了Python编程中,用sndhdr模块识别音频格式的相关内容,具体如下。 sndhdr模块 功能描述:sndhdr模块提供检测音频类型的接口。 唯一一个API sndhdr...

python 测试实现方法

 1)doctest 使用doctest是一种类似于命令行尝试的方式,用法很简单,如下 复制代码 代码如下:def f(n): """ >>> f(1) 1...