DongjunLee / conversation-tensorflow

TensorFlow implementation of Conversation Models
143 stars 27 forks source link

chat issue #1

Closed abhishekkritarth closed 6 years ago

abhishekkritarth commented 6 years ago

Hi @DongjunLee , My stack comprises of - Python -3.6 Tensorflow -1.4 hb-config - 0.3.4

I have gone through your code, i have pre processed the data and kept it for training. But, during chat i used below command but i'm facing following error - command : python chat.py --config check_tiny

load vocab ...

hi Traceback (most recent call last): File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 686, in _call_cpp_shape_fn_impl input_tensors_as_shapes, status) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot reshape a tensor with 16 elements to shape [1,5,16] (80 elements) for 'decoder/decode/Reshape' (op: 'Reshape') with input shapes: [1,16], [3] and with input tensors computed as partial shapes: input[1] = [1,5,16].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "chat.py", line 95, in main() File "chat.py", line 77, in main answer = chat(ids, vocab) File "chat.py", line 29, in chat prediction = next(result)["prediction"]

File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 411, in predict features, None, model_fn_lib.ModeKeys.PREDICT, self.config) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 694, in _call_model_fn model_fn_results = self._model_fn(features=features, *kwargs) File "/home/abhi/PycharmProjects/conversation-tensorflow-master/model.py", line 23, in model_fn self.build_graph() File "/home/abhi/PycharmProjects/conversation-tensorflow-master/model.py", line 63, in build_graph self._build_decoder() File "/home/abhi/PycharmProjects/conversation-tensorflow-master/model.py", line 184, in _build_decoder self.decoder_pred_outputs = decode() File "/home/abhi/PycharmProjects/conversation-tensorflow-master/model.py", line 145, in decode length_penalty_weight=Config.predict.length_penalty_weight) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/contrib/seq2seq/python/ops/beam_search_decoder.py", line 226, in init initial_state, self._cell.state_size) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 413, in map_structure structure[0], [func(x) for x in entries]) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 413, in structure[0], [func(*x) for x in entries]) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/contrib/seq2seq/python/ops/beam_search_decoder.py", line 407, in _maybe_split_batch_beams return self._split_batch_beams(t, s) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/contrib/seq2seq/python/ops/beam_search_decoder.py", line 372, in _split_batch_beams ([self._batch_size, self._beam_width], t_shape[1:]), 0)) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2958, in create_op set_shapes_for_outputs(ret) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs shapes = shape_func(op) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn require_shape_fn) File "/home/abhi/virtual-3.6/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl raise ValueError(err.message) ValueError: Cannot reshape a tensor with 16 elements to shape [1,5,16] (80 elements) for 'decoder/decode/Reshape' (op: 'Reshape') with input shapes: [1,16], [3] and with input tensors computed as partial shapes: input[1] = [1,5,16].

Please resolve this issue as soon as possible

junbeomlee commented 6 years ago

pull the latest version. This error was fixed by including beam search alg. But there is another issue which is "use uninitialized decoder_initial_state". This error can be handled by adding two lines of code: decoder_initial_state = out_cell.zero_state(Config.train.batch_size, self.dtype) decoder_initial_state.clone(cell_state=self.encoder_final_state) in 177 line in model.py. I edited this problem and made a pull request.

DongjunLee commented 6 years ago

@junbeomlee Thanks a lot. 👍

Hi @abhishekkritarth Let me know when occur same error after pull the latest version. :)