无效的参数:必须具有updates.shape = indexs.shape [:batch_dim] + params_shape [slice_dim:]

时间:2019-01-10 04:04:25

标签: tensorflow

我想用我的训练模型测试一些示例,但是在测试过程中会发生错误,请告诉我我的代码中的错误集中在第94行:

 line90:var_output_2 = tf.Variable(0, dtype=tf.float32,name="a",trainable=False,validate_shape=False)
 line91: row_vector = tf.gather_nd(word_embeddings, self.word_error_embed, name="a_word_error_embed")
 line92: sum_all = tf.reduce_sum(row_vector, 1, name="a_reduce_sum")
 line93: var_output_3=tf.assign(var_output_2, word_embeddings, validate_shape=False)
 line94: word_embeddings = tf.scatter_nd_update(var_output_3, self.error_word, sum_all)

控制台错误如下:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Must have updates.shape = indices.shape[:batch_dim] + params_shape[slice_dim:], got updates.shape: [7,300], indices.shape: [7,1], params_shape: [7,9,300], slice_dim: 1, and batch_dim: 1
     [[Node: words/ScatterNdUpdate = ScatterNdUpdate[T=DT_FLOAT, Tindices=DT_INT32, _class=["loc:@words/a"], use_locking=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](words/Assign, _arg_word_error_embed_2_0_4/_57, words/a_reduce_sum)]]

0 个答案:

没有答案