回答

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個問題:)

相關問題