ValueError: The two structures don't have the same number of elements

前端 未结 1 1416
鱼传尺愫
鱼传尺愫 2020-12-17 15:49
with tf.variable_scope(\'forward\'):
  cell_img_fwd = tf.nn.rnn_cell.GRUCell(hidden_state_size, hidden_state_size)
  img_init_state_fwd = rnn_img_mapped[:, 0, :]
  i         


        
相关标签:
1条回答
  • 2020-12-17 16:24

    Hello I had the same problem, I tried to do this:

    highest = tf.map_fn(lambda x : (-x, x), indices)
    

    This gave me a similar error message:

    ValueError: The two structures don't have the same number of elements.
    
    First structure (1 elements): <dtype: 'int32'>
    
    Second structure (2 elements): (<tf.Tensor 'map/while/Neg:0' shape=() dtype=int32>, <tf.Tensor 'map/while/TensorArrayReadV3:0' shape=() dtype=int32>)
    

    I resolved this by making the dtypes explicit:

    highest = tf.map_fn(lambda x : (-x, x), indices, dtype=(tf.int32, tf.int32))
    
    0 讨论(0)
提交回复
热议问题