关于训练
Created by: 447zyg
Pass 0, Batch 0, Cost 2.370898, {'classification_error_evaluator': 0.890625} ................................................................................................... Pass 0, Batch 100, Cost 2.261713, {'classification_error_evaluator': 0.8359375} ................................................................................................... Pass 0, Batch 200, Cost 1.884562, {'classification_error_evaluator': 0.7421875} ................................................................................................... Pass 0, Batch 300, Cost 1.898232, {'classification_error_evaluator': 0.7265625} .......................................................................................... Pass 1, Batch 0, Cost 1.824807, {'classification_error_evaluator': 0.734375} ................................................................................................... Pass 1, Batch 100, Cost 1.737753, {'classification_error_evaluator': 0.7265625} ................................................................................................... Pass 1, Batch 200, Cost 1.686236, {'classification_error_evaluator': 0.703125} ...................................................................................................
这些是什么意思 能解释下吗。。
然后我跑了一个demo
昨天下午跑到现在。。
Pass 30, Batch 200, Cost 0.404265, {'classification_error_evaluator': 0.1640625}
...................................................................................................
Pass 30, Batch 300, Cost 0.360163, {'classification_error_evaluator': 0.1171875}
..........................................................................................
Pass 31, Batch 0, Cost 0.248703, {'classification_error_evaluator': 0.078125}
.................
我是不是弄错了什么了。。
跑的这个。。
import paddle.v2 as paddle import sys
def train(): paddle.init(use_gpu=False, trainer_count=1) data_dim = 3 * 32 * 32 class_dim = 10 image = paddle.layer.data( name="image", type=paddle.data_type.dense_vector(data_dim)) net = vgg_bn_drop(image) out = paddle.layer.fc(input=net, size=class_dim, act=paddle.activation.Softmax()) lbl = paddle.layer.data( name="label", type=paddle.data_type.integer_value(class_dim)) cost = paddle.layer.classification_cost(input=out, label=lbl) parameters = paddle.parameters.create(cost) print(parameters.keys()) momentum_optimizer = paddle.optimizer.Momentum( momentum=0.9, regularization=paddle.optimizer.L2Regularization(rate=0.0002 * 128), learning_rate=0.1 / 128.0, learning_rate_decay_a=0.1, learning_rate_decay_b=50000 * 100, learning_rate_schedule='discexp') # Create trainer trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, update_equation=momentum_optimizer) reader = paddle.batch( paddle.reader.shuffle( paddle.dataset.cifar.train10(), buf_size=50000), batch_size=128) feeding = {'image': 0, 'label': 1} trainer.train( reader=reader, num_passes=200, event_handler=event_handler, feeding=feeding)
def vgg_bn_drop(input_data): def convolution_block(ipt, num_filter, groups, dropouts, num_channels=None): return paddle.networks.img_conv_group( input=ipt, num_channels=num_channels, pool_size=2, pool_stride=2, conv_num_filter=[num_filter] * groups, conv_filter_size=3, conv_act=paddle.activation.Relu(), conv_with_batchnorm=True, conv_batchnorm_drop_rate=dropouts, pool_type=paddle.pooling.Max()) convolution_1 = convolution_block(input_data, 64, 2, [0.3, 0], 3) convolution_2 = convolution_block(convolution_1, 128, 2, [0.4, 0]) convolution_3 = convolution_block(convolution_2, 256, 3, [0.4, 0.4, 0]) convolution_4 = convolution_block(convolution_3, 512, 3, [0.4, 0.4, 0]) convolution_5 = convolution_block(convolution_4, 512, 3, [0.4, 0.4, 0]) drop = paddle.layer.dropout(input=convolution_5, dropout_rate=0.5) fc1 = paddle.layer.fc(input=drop, size=512, act=paddle.activation.Linear()) bn = paddle.layer.batch_norm( input=fc1, act=paddle.activation.Relu(), layer_attr=paddle.attr.Extra(drop_rate=0.5)) fc2 = paddle.layer.fc(input=bn, size=512, act=paddle.activation.Linear()) return fc2
def event_handler(event): if isinstance(event, paddle.event.EndIteration): if event.batch_id % 100 == 0: print("\nPass %d, Batch %d, Cost %f, %s" % ( event.pass_id, event.batch_id, event.cost, event.metrics)) else: sys.stdout.write('.') sys.stdout.flush()
if name == 'main': train()
下了个cifar-10-python.tar.gz 感谢。