thu-coai / ecm

This project is a tensorflow implement of our work, ECM (emotional chatting machine).
Apache License 2.0
217 stars 77 forks source link

InvalidArgumentError #14

Open MaCYbupt opened 6 years ago

MaCYbupt commented 6 years ago

我在用data中的小规模数据训练的时候出现了下面的错误,因为数据规模小,所以同时将post和response词表的大小都改成了100,不知道有没有这方面的原因。


Caused by op _u'model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/Reshape_3',_` defined at:
  File "baseline.py", line 392, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "baseline.py", line 388, in main
    train()
  File "baseline.py", line 195, in train
    model = create_model(sess, False, False)
  File "baseline.py", line 139, in create_model
    dtype=dtype)
  File "/home/emotion_generation/mcy/ecm/seq2seq_model.py", line 157, in __init__
    softmax_loss_function=softmax_loss_function, use_imemory=use_imemory, use_ememory=use_ememory)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 1322, in model_with_buckets
    decoder_inputs[:bucket[1]], decoder_emotions)
  File "/home/emotion_generation/mcy/ecm/seq2seq_model.py", line 156, in <lambda>
    lambda x, y, z: seq2seq_f(x, y, z, False),
  File "/home/emotion_generation/mcy/ecm/seq2seq_model.py", line 119, in seq2seq_f
    beam_size=beam_size)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 1171, in embedding_attention_seq2seq
    beam_size=beam_size)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 1055, in embedding_attention_decoder
    initial_state_attention=initial_state_attention)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 701, in attention_decoder
    s1 = tf.nn.softmax(output1, dim=0) * g
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1667, in softmax
    return _softmax(logits, gen_nn_ops._softmax, dim, name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1630, in _softmax
    logits = _flatten_outer_dims(logits)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1551, in _flatten_outer_dims
    output = array_ops.reshape(logits, array_ops.concat([[-1], last_dim_size], 0))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape
    "Reshape", tensor=tensor, shape=shape, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero
     [[Node: model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/Reshape_3 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/transpose_3, model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/concat_6)]]
     [[Node: clip_by_global_norm_1/mul_8/_1657 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_21552_clip_by_global_norm_1/mul_8", tensor_type=DT_FLOAT, `_device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]```
Yijun-Mao commented 5 years ago

我在用data中的小规模数据训练的时候出现了下面的错误,因为数据规模小,所以同时将post和response词表的大小都改成了100,不知道有没有这方面的原因。

Caused by op _u'model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/Reshape_3',_` defined at:
  File "baseline.py", line 392, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "baseline.py", line 388, in main
    train()
  File "baseline.py", line 195, in train
    model = create_model(sess, False, False)
  File "baseline.py", line 139, in create_model
    dtype=dtype)
  File "/home/emotion_generation/mcy/ecm/seq2seq_model.py", line 157, in __init__
    softmax_loss_function=softmax_loss_function, use_imemory=use_imemory, use_ememory=use_ememory)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 1322, in model_with_buckets
    decoder_inputs[:bucket[1]], decoder_emotions)
  File "/home/emotion_generation/mcy/ecm/seq2seq_model.py", line 156, in <lambda>
    lambda x, y, z: seq2seq_f(x, y, z, False),
  File "/home/emotion_generation/mcy/ecm/seq2seq_model.py", line 119, in seq2seq_f
    beam_size=beam_size)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 1171, in embedding_attention_seq2seq
    beam_size=beam_size)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 1055, in embedding_attention_decoder
    initial_state_attention=initial_state_attention)
  File "/home/emotion_generation/mcy/ecm/seq2seq.py", line 701, in attention_decoder
    s1 = tf.nn.softmax(output1, dim=0) * g
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1667, in softmax
    return _softmax(logits, gen_nn_ops._softmax, dim, name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1630, in _softmax
    logits = _flatten_outer_dims(logits)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1551, in _flatten_outer_dims
    output = array_ops.reshape(logits, array_ops.concat([[-1], last_dim_size], 0))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape
    "Reshape", tensor=tensor, shape=shape, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero
   [[Node: model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/Reshape_3 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/transpose_3, model_with_buckets/embedding_attention_seq2seq_1/embedding_attention_decoder/attention_decoder/concat_6)]]
   [[Node: clip_by_global_norm_1/mul_8/_1657 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_21552_clip_by_global_norm_1/mul_8", tensor_type=DT_FLOAT, `_device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]```

您好,我也遇到这个问题了。请问最后你解决了吗?是如何解决的?

luomuqinghan commented 5 years ago

同样遇到这个问题,请问解决了吗? 目测是因为response中的词不出现在emotion-Vocab中。 但是保证每个response在emotion-Vocab都有词合理吗?