提交 828303bd 编写于 作者: W wangyang59

after clang-format

上级 ff4e0463
from paddle.trainer.PyDataProvider2 import * from paddle.trainer.PyDataProvider2 import *
import numpy import numpy
# Define a py data provider # Define a py data provider
@provider( @provider(
input_types={'pixel': dense_vector(28 * 28), input_types={'pixel': dense_vector(28 * 28),
...@@ -20,13 +21,14 @@ def process(settings, filename): # settings is not used currently. ...@@ -20,13 +21,14 @@ def process(settings, filename): # settings is not used currently.
n = 60000 n = 60000
else: else:
n = 10000 n = 10000
images = numpy.fromfile(f, 'ubyte', count=n*28*28).reshape((n, 28*28)).astype('float32') images = numpy.fromfile(
images = images / 255.0 * 2.0 - 1.0 f, 'ubyte', count=n * 28 * 28).reshape((n, 28 * 28)).astype('float32')
images = images / 255.0 * 2.0 - 1.0
labels = numpy.fromfile(l, 'ubyte', count=n).astype("int") labels = numpy.fromfile(l, 'ubyte', count=n).astype("int")
for i in xrange(n): for i in xrange(n):
yield {"pixel": images[i, :], 'label': labels[i]} yield {"pixel": images[i, :], 'label': labels[i]}
f.close() f.close()
l.close() l.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册