Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

基于栈式双向LSTM的情感识别 GPU训练报错 #849

Open
AlucardNosferatu opened this issue Apr 18, 2020 · 2 comments
Open

基于栈式双向LSTM的情感识别 GPU训练报错 #849

AlucardNosferatu opened this issue Apr 18, 2020 · 2 comments

Comments

@AlucardNosferatu
Copy link

step: 194, Metrics [array([0.24539784], dtype=float32), array([0.921875], dtype=float32)]
step: 195, Metrics [array([0.4097221], dtype=float32), array([0.8], dtype=float32)]
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py:782: UserWarning: The following exception is not an EOF exception.
"The following exception is not an EOF exception.")
Traceback (most recent call last):
File "SA_Test.py", line 252, in
main(use_cuda)
File "SA_Test.py", line 246, in main
infer(use_cuda, params_dirname)
File "SA_Test.py", line 234, in infer
return_numpy=False)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 783, in run
six.reraise(*sys.exc_info())
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 778, in run
use_program_cache=use_program_cache)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 831, in _run_impl
use_program_cache=use_program_cache)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 902, in _run_program
self._feed_data(program, feed, feed_var_name, scope)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 580, in _feed_data
check_feed_shape_type(var, cur_feed)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 230, in check_feed_shape_type
(var.name, len(var.shape), var.shape, feed_shape))
ValueError: The feeded Variable 'words' should have dimensions = 1, shape = (-1,), but received feeded shape [-1, 1] on each device

用的代码:https://github.com/PaddlePaddle/book/blob/develop/06.understand_sentiment/train_stacked_lstm.py
没有修改任何部分 运行指令:
python SA_Test.py --use_gpu 1

@AlucardNosferatu
Copy link
Author

动态rnn也报了一样的错:

Step 189, Epoch 0 Metrics [array([0.45252907], dtype=float32), array([0.8046875], dtype=float32)]
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py:782: UserWarning: The following exception is not an EOF exception.
"The following exception is not an EOF exception.")
Traceback (most recent call last):
File "SA_Test.py", line 231, in
main(use_cuda)
File "SA_Test.py", line 225, in main
infer(use_cuda, params_dirname)
File "SA_Test.py", line 213, in infer
return_numpy=False)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 783, in run
six.reraise(*sys.exc_info())
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 778, in run
use_program_cache=use_program_cache)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 831, in _run_impl
use_program_cache=use_program_cache)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 902, in _run_program
self._feed_data(program, feed, feed_var_name, scope)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 580, in _feed_data
check_feed_shape_type(var, cur_feed)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 230, in check_feed_shape_type
(var.name, len(var.shape), var.shape, feed_shape))
ValueError: The feeded Variable 'words' should have dimensions = 1, shape = (-1,), but received feeded shape [-1, 1] on each device

@miaomiao3
Copy link

miaomiao3 commented Jun 3, 2020

同样遇到这个问题。仔细对照了网页版,和最新的代码是有区别的。
shape = (-1,)的要求,可以把lod转换ndarray
生成lod_tensor之前,加一行
lod = np.array(sum(lod, []), dtype=np.int64)
这样就可以跑通

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants