-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
运行示例中的代码,得到错误:reduce() of empty sequence with no initial value #2564
Comments
Can you paste the code? I'm not sure about this error now? Please make sure that data_reader has no problem |
具体代码请见:http://www.paddlepaddle.org/doc_cn/getstarted/concepts/use_concepts_cn.html 我安装好paddle之后,编辑该代码到【linear.py】文件,然后键入命令【python linear.py】 |
@chrisxu2016 any update? |
To confirm, I did not have this problem before. I was able to input numpy nd array with multiple samples without problem with the paddle build 1 month ago. I rebuilt it yesterday, and I now have this problem. So I think there have been some commits which break the infer function |
The demo code have some error, the input value is configured as y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1)) but the reader yeild a scalar: def train_reader():
train_x = np.array([[1, 1], [1, 2], [3, 4], [5, 2]])
train_y = np.array([-2, -3, -7, -7])
def reader():
for i in xrange(train_y.shape[0]):
yield train_x[i], train_y[i]
return reader the reader should be changed to: def train_reader():
train_x = np.array([[1, 1], [1, 2], [3, 4], [5, 2]])
train_y = np.array([[-2], [-3], [-7], [-7]])
def reader():
for i in xrange(train_y.shape[0]):
yield train_x[i], train_y[i]
return reader |
Thank you @jacquesqiao, it works now. |
新建了一个python文件,照抄了新手入门的线性回归代码。
运行该python的时候得到错误:
The text was updated successfully, but these errors were encountered: