回答

0

列表

错误1:

TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32.

来自:x = tf.split(0, n_chunks, x)
到:x = tf.split(axis=0, num_or_size_splits=n_chunks, value=x)

错误2:

AttributeError: module 'tensorflow.contrib.rnn.python.ops.rnn_cell' has no attribute '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: name 'rnn' is not defined

来自: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: Dimension must be 2 but is 3 for 'transpose_3' (op: 'Transpose') with input shapes: [?,28], [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: Only call softmax_cross_entropy_with_logits with named arguments (labels=..., 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 and labels must be same size: logits_size=[28,10] labels_size=[128,10]

这是一个也许概念问题与softmax_cross_entropy_with_logits功能。看看:softmax_cross_entropy_with_logitsdoc

开始理解和解决所有这些问题。如果仍然无法运行代码,请返回并发布更新后的代码,但至少需要解决6个问题:)

相关问题