TensorFlow遇到的问题汇总(持续更新中……) – 猎手家园

1、调用 tf.功能。

#原因是这个函数,不能按以前的方式进行调用了,只能使用命名参数的方式来调用。
#原来是这样的:
tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y, y_))
#修改成这样的:
tf.reduce_sum(tf.nn.softmax_cross_entropy_with_logits(logits=y, labels=y_))

2、 tf.cocat([fw,bw],2)Error: int32, got list of type ‘’ .

int32,得到类型为“” inst的列表

原因是版本11的函数形式为:tf.(2,[fw,bw]),即要交换连接的维度和连接值的位置。

3、’Split’ Op 的输入”的类型与 int32 的类型不匹配

#原来是这样的:
This is because in Tensorflow versions < 0.12.0 the split function takes the arguments as:
x = tf.split(0, n_steps, x) # tf.split(axis, num_or_size_splits, value)
#修改成这样的:
The tutorial you are working from was written for versions > 0.12.0, which has been changed to be consistent with Numpy’s split syntax:
x = tf.split(x, n_steps, 0) # tf.split(value, num_or_size_splits, axis)

4、‘’没有‘包’

因为后来的TF版本改了这个函数的名字,所以把tf.pack改成了tf.stack。

5、feed 的值是一个 tf. . feed , , lists 或 numpy

数据集由feed输入,需要feed的数据格式。

解决方法:img,label = sess.run[img,label],使用返回值。

6、 ‘..ops.nn’ 没有”

#原因是1.0版本改了不少地方啊...
#原来是这样的:
from tensorflow.python.ops import rnn, rnn_cell 
lstm_cell = rnn_cell.BasicLSTMCell(rnn_size,state_is_tuple=True) 
outputs, states = rnn.rnn(lstm_cell, x, dtype=tf.float32)
#修改成这样的:
from tensorflow.contrib import rnn 
lstm_cell = rnn.BasicLSTMCell(rnn_size) 
outputs, states = rnn.static_rnn(lstm_cell, x, dtype=tf.float32)

7、 basic/rnn// 不存在,或者不带 tf.()。您的意思是在 中设置reuse=None 吗?

with tf.variable_scope(scope_name, reuse=None) as scope:
    scope.reuse_variables()
    w = tf.get_variable("weight", shape, initializer = random_normal_initializer(0., 0.01)))
    b = tf.get_variable("biase", shape[-1], initializer = tf.constant_initializer(0.0))
#或:
with tf.variable_scope(scope_name, reuse=True):
    w = tf.get_variable("weight")
    b = tf.get_variable("biase")

© 版权声明
THE END
喜欢就支持一下吧
点赞12赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容