diff --git a/demo/mnist/api_train.py b/demo/mnist/api_train.py new file mode 100644 index 0000000000000000000000000000000000000000..6abb5d4e562ee9d24a1f914757f3b8e4a3e5cb12 --- /dev/null +++ b/demo/mnist/api_train.py @@ -0,0 +1,12 @@ +import py_paddle.swig_paddle as api +from paddle.trainer.config_parser import parse_config + + +def main(): + api.initPaddle("-use_gpu=false", "-trainer_count=4") # use 4 cpu cores + config = parse_config('simple_mnist_network.py', '') + m = api.GradientMachine.createFromConfigProto(config.model_config) + + +if __name__ == '__main__': + main() diff --git a/demo/mnist/simple_mnist_network.py b/demo/mnist/simple_mnist_network.py new file mode 100644 index 0000000000000000000000000000000000000000..41f4e51657d35bf72401f4076c53b7b3bf7d5b52 --- /dev/null +++ b/demo/mnist/simple_mnist_network.py @@ -0,0 +1,16 @@ +from paddle.trainer_config_helpers import * + +settings(learning_rate=1e-4, learning_method=AdamOptimizer(), batch_size=1000) + +imgs = data_layer(name='pixel', size=784) + +hidden1 = fc_layer(input=imgs, size=200) +hidden2 = fc_layer(input=hidden1, size=200) + +inference = fc_layer(input=hidden2, size=10, act=SoftmaxActivation()) + +cost = classification_cost( + input=inference, label=data_layer( + name='label', size=10)) + +outputs(cost)