paddle 主页,quick start 中,recognize digits例子跑不通
http://book.paddlepaddle.org/index.html 主页中recognize digits的例子跑不通,怀疑是paddle.v2.dataset.mnist.train() 返回的数据格式不正确引起的。
报错如下:
Traceback (most recent call last):
File "main.py", line 104, in
我的代码如下:
def convolutional_neural_network(img):
conv_pool_1 = paddle.networks.simple_img_conv_pool(
input=img,
filter_size=5,
num_filters=20,
num_channel=1,
pool_size=2,
pool_stride=2,
act=paddle.activation.Relu())
conv_pool_2 = paddle.networks.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
num_filters=50,
num_channel=20,
pool_size=2,
pool_stride=2,
act=paddle.activation.Relu())
predict = paddle.layer.fc(input=conv_pool_2,
size=10,
act=paddle.activation.Softmax())
return predict
paddle.init(use_gpu=False, trainer_count=1)
images = paddle.layer.data(name='pixel', type=paddle.data_type.dense_vector(784))
label = paddle.layer.data(name='label', type=paddle.data_type.dense_vector(10))
predict = convolutional_neural_network(images)
cost = paddle.layer.classification_cost(input=predict, label=label)
parameters = paddle.parameters.create(cost)
optimizer = paddle.optimizer.Momentum( learning_rate=0.1/128, momentum=0.9)
trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, update_equation=optimizer)
simple_reader = paddle.dataset.mnist.train() shuffle_reader = paddle.reader.shuffle(simple_reader, buf_size=8192) batch_reader = paddle.batch(shuffle_reader, batch_size=1)
trainer.train( reader = batch_reader, num_passes=1)
Thank you for contributing to PaddlePaddle. Submitting an issue is a great help for us. Both Chinese and English issues are welcome.
It's hard to solve a problem when important details are missing. Before submitting the issue, look over the following criteria before handing your request in.
- [ ] Was there a similar issue submitted or resolved before ? You could search issue in the github.
- [ ] Did you retrieve your issue from widespread search engines ?
- [ ] Is my description of the issue clear enough to reproduce this problem?
- If some errors occurred, we need details about
how do you run your code?,what system do you use?,Are you using GPU or not?, etc. - If you use an recording asciinema to show what you are doing to make it happen, that's awesome! We could help you solve the problem more quickly.
- If some errors occurred, we need details about
- [ ] Is my description of the issue use the github markdown correctly?
- Please use the proper markdown syntaxes for styling all forms of writing, e.g, source code, error information, etc.
- Check out this page to find out much more about markdown.
目前发现一个配置错误。
将
paddle.data_type.dense_vector(10))
改为
paddle.data_type.integer_value(10))
就可以了。