mnist_provider.py 389 字节
Newer Older
W
wangyang59 已提交
1
from paddle.trainer.PyDataProvider2 import *
Y
Yu Yang 已提交
2
from mnist_util import read_from_mnist
W
wangyang59 已提交
3

W
wangyang59 已提交
4

W
wangyang59 已提交
5
# Define a py data provider
6 7
@provider(
    input_types={'pixel': dense_vector(28 * 28),
W
wangyang59 已提交
8 9
                 'label': integer_value(10)},
    cache=CacheType.CACHE_PASS_IN_MEM)
W
wangyang59 已提交
10
def process(settings, filename):  # settings is not used currently.
Y
Yu Yang 已提交
11 12
    for each in read_from_mnist(filename):
        yield each