【发布时间】:2017-11-14 20:31:55
【问题描述】:
【问题讨论】:
-
错误是什么?
-
不要在此处共享文件。请添加代码。
标签: tensorflow deep-learning python-3.5 recurrent-neural-network
【问题讨论】:
标签: tensorflow deep-learning python-3.5 recurrent-neural-network
错误列表
错误 1:
TypeError: Input 'split_dim' of 'Split' Op 的 float32 类型与预期的 int32 类型不匹配。
发件人:x = tf.split(0, n_chunks, x)
收件人:x = tf.split(axis=0, num_or_size_splits=n_chunks, value=x)
错误 2:
AttributeError: 模块 'tensorflow.contrib.rnn.python.ops.rnn_cell' 没有属性 'BasicLSTMCell'
发件人:from tensorflow.contrib.rnn.python.ops import rnn_cell
lstm_cell = rnn_cell.BasicLSTMCell(rnn_size,state_is_tuple=True)
至:from tensorflow.contrib.rnn import BasicLSTMCell
lstm_cell = BasicLSTMCell(rnn_size,state_is_tuple=True)
错误 3:
NameError: 名称 'rnn' 未定义
发件人:outputs, states = rnn.rnn(lstm_cell, x, dtype=tf.float32)
致:outputs, states = tf.nn.dynamic_rnn(cell=lstm_cell, inputs=x, dtype=tf.float32)
错误 4:
ValueError:维度必须为 2,但对于输入形状为 [?,28]、[3] 的“transpose_3”(操作:“Transpose”)为 3。
评论:x = tf.transpose(x, [1,0,2])
x = tf.reshape(x, [-1, chunk_size])
x = tf.split(axis=0, num_or_size_splits=n_chunks, value=x)
错误 5:
ValueError:仅使用命名参数(labels=...、logits=...、...)调用
softmax_cross_entropy_with_logits
发件人:cost = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(prediction,y) )
致:cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=prediction,labels=y))
错误 6:
InvalidArgumentError:logits 和标签的大小必须相同:logits_size=[28,10] labels_size=[128,10]
这是softmax_cross_entropy_with_logits 函数的可能概念问题。看看:softmax_cross_entropy_with_logits和doc
开始了解并解决所有这些问题。如果您仍然无法运行代码,请返回并发布更新后的代码,但至少解决了这 6 个问题:)
【讨论】: