cn-deep-learning icon indicating copy to clipboard operation
cn-deep-learning copied to clipboard

ValueError: prefix tensor must be either a scalar or vector, but saw tensor: Tensor("Placeholder:0", dtype=int32)

Open SefaZeng opened this issue 7 years ago • 1 comments

when i run the get_ini_cell, there is something wrong with the function about InitialState = cell.zero_state(batch_size,tf.float32) The tensorflow version is 1.4 I wanna ask what can i do for the code cause my code is the same as others,but they dont meet such probelms. And when i run the build_nn,it also says ValueError: Dimensions must be equal, but are 512 and 556 for 'rnn/while/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/MatMul_1' (op: 'MatMul') with input shapes: [128,512], [556,1024].

SefaZeng avatar Mar 12 '18 02:03 SefaZeng

you can change this:

cell.zero_state(batch_size,tf.float32)

to

batch_size = tf.placeholder(tf.int32, [], name='batch_size')
cell.zero_state(batch_size, tf.float32)

it works.

guoqingzhi avatar Apr 18 '18 02:04 guoqingzhi