trainer_config.py 756 字节
Newer Older
1 2
from paddle.trainer_config_helpers import *

3 4 5 6 7
define_py_data_sources2(
    train_list='train.list',
    test_list='test.list',
    module='provider',
    obj='process')
8 9 10 11
settings(
    batch_size=128,
    learning_rate=1e-3,
    learning_method=AdamOptimizer(),
12
    regularization=L2Regularization(0.5))
13 14 15

img = data_layer(name='pixel', size=28 * 28)

16 17
hidden1 = simple_img_conv_pool(
    input=img, filter_size=3, num_filters=32, pool_size=3, num_channel=1)
18

19 20 21 22 23
hidden2 = fc_layer(
    input=hidden1,
    size=200,
    act=TanhActivation(),
    layer_attr=ExtraAttr(drop_rate=0.5))
24 25
predict = fc_layer(input=hidden2, size=10, act=SoftmaxActivation())

26 27 28 29
outputs(
    classification_cost(
        input=predict, label=data_layer(
            name='label', size=10)))