| 5 | from caffe import params as P |
| 6 | |
| 7 | def lenet(batch_size): |
| 8 | n = caffe.NetSpec() |
| 9 | n.data, n.label = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]), |
| 10 | dict(dim=[batch_size, 1, 1, 1])], |
| 11 | transform_param=dict(scale=1./255), ntop=2) |
| 12 | n.conv1 = L.Convolution(n.data, kernel_size=5, num_output=20, |
| 13 | weight_filler=dict(type='xavier')) |
| 14 | n.pool1 = L.Pooling(n.conv1, kernel_size=2, stride=2, pool=P.Pooling.MAX) |
| 15 | n.conv2 = L.Convolution(n.pool1, kernel_size=5, num_output=50, |
| 16 | weight_filler=dict(type='xavier')) |
| 17 | n.pool2 = L.Pooling(n.conv2, kernel_size=2, stride=2, pool=P.Pooling.MAX) |
| 18 | n.ip1 = L.InnerProduct(n.pool2, num_output=500, |
| 19 | weight_filler=dict(type='xavier')) |
| 20 | n.relu1 = L.ReLU(n.ip1, in_place=True) |
| 21 | n.ip2 = L.InnerProduct(n.relu1, num_output=10, |
| 22 | weight_filler=dict(type='xavier')) |
| 23 | n.loss = L.SoftmaxWithLoss(n.ip2, n.label) |
| 24 | return n.to_proto() |
| 25 | |
| 26 | def anon_lenet(batch_size): |
| 27 | data, label = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]), |