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

相关文章

Pytorch抽取网络层的Feature Map(Vgg)实例

这边我是需要得到图片在Vgg的5个block里relu后的Feature Map (其余网络只需要替换就可以了) 索引可以这样获得 vgg = models.vgg19(pretra...

python获取点击的坐标画图形的方法

获取输入的五个点画五边形 def pentagonUpdate(): p = {} win = GraphWin("Click", 800, 300)#后面两个值为窗体的长和...

python单线程实现多个定时器示例

单线程实现多个定时器 NewTimer.py复制代码 代码如下:#!/usr/bin/env python from heapq import *from threading impor...

pandas如何处理缺失值

在实际应用中对于数据进行分析的时候,经常能看见缺失值,下面来介绍一下如何利用pandas来处理缺失值。常见的缺失值处理方式有,过滤、填充。 一、缺失值的判断 pandas使用浮点值Na...

python 计算数组中每个数字出现多少次--“Bucket”桶的思想

python 计算数组中每个数字出现多少次--“Bucket”桶的思想

题目: 解法一:比较元素是否相等 思路说明: 这种应该是普通人最先想到的解法,先获取到数组之后进行有小到大排序,然后初始化一个min=0(代表新数字的开始角标),然后遍历新数组的每一个...