princewen/tensorflow_practice

楼主的chat_bot_seq2seq_attention能跑起来吗?

tyongguang opened this issue · 8 comments

发现一些小错啊?
比如:
train.py 中的
“model.restore(sess, ckpt.model_checkpoint_path)”
应改为:
"model.saver.restore(sess, ckpt.model_checkpoint_path)"

predict.py 中的
from data_helpers import loadDataset, getBatches, sentence2enco
应改为:
from data_loader import loadDataset, getBatches, sentence2enco

predict跑起来还有其它一屏又一屏的错,我只是想问一下楼主,是否真能跑起来?

把beam_search相关的注释打开才行。。。

看起来中文的项目确实漏洞百出啊

把beam_search相关的注释打开才行。。。

predict跑起来了吗

把beam_search相关的注释打开才行。。。

predict跑起来了吗

能predict 起来。但绝对不是你想像中那样子:
第一,输入输出都是英文
第二,效果很差

把beam_search相关的注释打开才行。。。

predict跑起来了吗

能predict 起来。但绝对不是你想像中那样子:
第一,输入输出都是英文
第二,效果很差

嗯嗯,跑起来了,训练数据都是英文的,输入中文的话不知道能不能理解,确实答非所问

把beam_search相关的注释打开才行。。。

predict跑起来了吗

能predict 起来。但绝对不是你想像中那样子:
第一,输入输出都是英文
第二,效果很差

嗯嗯,跑起来了,训练数据都是英文的,输入中文的话不知道能不能理解,确实答非所问

请问tf版本是多少?我在predict出错了。
报错如下:

2019-12-17 14:15:28.290374: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290477: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290502: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290489: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290570: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290810: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290841: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
Traceback (most recent call last):
  File "/home/zsq/anaconda3/envs/tf1.4/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
    return fn(*args)
  File "/home/zsq/anaconda3/envs/tf1.4/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
    status, run_metadata)
  File "/home/zsq/anaconda3/envs/tf1.4/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: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
	 [[Node: encoder/rnn/All/_55 = _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_69_encoder/rnn/All", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

把beam_search相关的注释打开才行。。。

predict跑起来了吗

能predict 起来。但绝对不是你想像中那样子:
第一,输入输出都是英文
第二,效果很差

嗯嗯,跑起来了,训练数据都是英文的,输入中文的话不知道能不能理解,确实答非所问

请问tf版本是多少?我在predict出错了。
报错如下:

2019-12-17 14:15:28.290374: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290477: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290502: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290489: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290570: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290810: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
2019-12-17 14:15:28.290841: W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
Traceback (most recent call last):
  File "/home/zsq/anaconda3/envs/tf1.4/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
    return fn(*args)
  File "/home/zsq/anaconda3/envs/tf1.4/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
    status, run_metadata)
  File "/home/zsq/anaconda3/envs/tf1.4/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: Input to reshape is a tensor with 1024 values, but the requested shape has 5120
	 [[Node: decoder/Reshape_4 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](decoder/AttentionWrapperZeroState/zeros_1, decoder/concat_4)]]
	 [[Node: encoder/rnn/All/_55 = _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_69_encoder/rnn/All", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

不是tf的问题,训练和预测时不要用beam_search(beam_search=False)