浅谈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设计】。

相关文章

Pycharm2017版本设置启动时默认自动打开项目的方法

Pycharm2017版本设置启动时默认自动打开项目的方法

最新版本不同于旧版本的设置,网上检索一番方法都不适用。 新版的设置位置在“configure->setting->Appearance&Behavior->System...

Python加密方法小结【md5,base64,sha1】

本文实例总结了python加密方法。分享给大家供大家参考,具体如下: MD5加密: def md5(str): import hashlib m = hashlib.md5(...

Django文件上传与下载(FileFlid)

Django文件上传与下载(FileFlid)

本文实例为大家分享了Django文件上传与下载的具体代码,供大家参考,具体内容如下 Django1.4 首先是上传: #settings.py MEDIA_ROOT = HERE#定义一...

python3.5仿微软计算器程序

本文实例为大家分享了python3.5仿微软计算器的具体代码,供大家参考,具体内容如下 from tkinter import * from math import * root =...

一文带你了解Python中的字符串是什么

一文带你了解Python中的字符串是什么

在《 详解Python拼接字符串的七种方式 》这篇文章里,我提到过,字符串是程序员离不开的事情。后来,我看到了一个英文版本的说法: There are few guarantees in...