def ResNet_cifar( mode='train',root_path='',batch_size=32,block_n=3): network='name:"ResNet-20"'+'\n' if mode=='train': network,last_name=write_prototxt.data(network,name="Data1",mirror=True,scale=0.00390625,crop_size=32,batch_size=batch_size,backend="LMDB",shuffle=True,datasets_path=root_path) use_global_stats=False elif mode=='test': network,last_name=write_prototxt.data(network,name="Data1",mirror=False,scale=0.00390625,crop_size=32,batch_size=batch_size,backend="LMDB",shuffle=False,datasets_path=root_path) use_global_stats=True network,last_name=write_prototxt.Convolution(network,name="conv1",bottom_name=last_name,top_name='conv1',num_output=16, bias_term=True,pad=1,kernel_size=3,stride=1,weight_type='msra',bias_type='constant') network,last_name=write_prototxt.BatchNorm(network,name_bn="conv1/bn",name_scale="conv1/scale", bottom_name="conv1",top_name="conv1",use_global_stats=use_global_stats) network,last_name=write_prototxt.ReLU(network,name="conv1/ReLU",bottom_name='conv1',top_name='conv1') #network=Pooling(network,name="Pooling1",bottom_name='conv1',top_name='Pooling1',pool='MAX') network,last_name=ResBlock(network,last_name=last_name,block_name='conv2_',block_n=block_n,num_out=16,downsampling=False,use_global_stats=use_global_stats) network,last_name=ResBlock(network,last_name=last_name,block_name='conv3_',block_n=block_n,num_out=32,downsampling=True,down_method='conv',use_global_stats=use_global_stats) network,last_name=ResBlock(network,last_name=last_name,block_name='conv4_',block_n=block_n,num_out=64,downsampling=True,down_method='conv',use_global_stats=use_global_stats) #network,last_name=ResBlock(network,last_name=last_name,block_name='conv5_',block_n=block_n,num_out=64,downsampling=True,down_method='conv',use_global_stats=use_global_stats) network,last_name=write_prototxt.Pooling(network,name="Pooling1",bottom_name=last_name,top_name='Pooling1',pool='AVE',global_pooling=True) network,last_name=write_prototxt.InnerProduct(network,name="fc1",bottom_name=last_name,top_name='fc1',num_output=10,weight_type='msra',bias_type='constant') #if mode=='train': network,last_name=write_prototxt.SoftmaxWithLoss(network,name="Softmax1",bottom_name1='fc1',bottom_name2='label',top_name='Softmax1') if mode=='test': network,last_name=write_prototxt.Accuracy(network,name="prob",bottom_name1='fc1',bottom_name2='label',top_name='prob') # # print network return network
def Net( mode='train',root_path='',batch_size=32): network='name:"MnasNet"'+'\n' if mode=='train': network,last_name=write_prototxt.data(network,name="data",mirror=True,scale=0.00390625,crop_size=224,batch_size=batch_size,backend="LMDB",shuffle=True,datasets_path=root_path) use_global_stats=False elif mode=='test': network,last_name=write_prototxt.data(network,name="data",mirror=False,scale=0.00390625,crop_size=224,batch_size=batch_size,backend="LMDB",shuffle=False,datasets_path=root_path) use_global_stats=True elif mode=='deploy': network='input: "data"'+'\n' network=network+'input_dim: 1'+'\n' network=network+'input_dim: 3'+'\n' network=network+'input_dim: 224'+'\n' network=network+'input_dim: 224'+'\n' last_name="data" use_global_stats=True network,last_name=write_prototxt.Convolution(network,name="conv1",bottom_name=last_name,top_name='conv1',num_output=32, bias_term=False,pad=1,kernel_size=3,stride=2,weight_type='msra',bias_type='constant') network,last_name=write_prototxt.BatchNorm(network,name_bn="conv1/bn",name_scale="conv1/scale", bottom_name="conv1",top_name="conv1",use_global_stats=use_global_stats) network,last_name=write_prototxt.ReLU(network,name="conv1/ReLU",bottom_name='conv1',top_name='conv1') network,last_name=MnasNet_block_first(network,last_name=last_name,block_name='conv2_1', block_n=1,num_out1=32,num_out2=16,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv3_1', block_n=1,kernel_size=3,num_out1=48,num_out2=24,downsampling=True,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv3_2', block_n=1,kernel_size=3,num_out1=72,num_out2=24,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv3_3', block_n=1,kernel_size=3,num_out1=72,num_out2=24,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv4_1', block_n=1,kernel_size=5,num_out1=72,num_out2=40,downsampling=True,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv4_2', block_n=1,kernel_size=5,num_out1=120,num_out2=40,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv4_3', block_n=1,kernel_size=5,num_out1=120,num_out2=40,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv5_1', block_n=1,kernel_size=5,num_out1=240,num_out2=80,downsampling=True,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv5_2', block_n=1,kernel_size=5,num_out1=480,num_out2=80,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv5_3', block_n=1,kernel_size=5,num_out1=480,num_out2=80,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv6_1', block_n=1,kernel_size=3,num_out1=480,num_out2=96,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv6_2', block_n=1,kernel_size=3,num_out1=576,num_out2=96,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv7_1', block_n=1,kernel_size=5,num_out1=576,num_out2=192,downsampling=True,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv7_2', block_n=1,kernel_size=5,num_out1=1152,num_out2=192,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv7_3', block_n=1,kernel_size=5,num_out1=1152,num_out2=192,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv7_4', block_n=1,kernel_size=5,num_out1=1152,num_out2=192,downsampling=False,use_global_stats=use_global_stats) network,last_name=MnasNet_block_bdce(network,last_name=last_name,block_name='conv8_1', block_n=1,kernel_size=3,num_out1=1152,num_out2=320,downsampling=False,use_global_stats=use_global_stats) network,last_name=write_prototxt.Pooling(network,name="Pooling1",bottom_name=last_name,top_name='Pooling1',pool='AVE',global_pooling=True) network,last_name=write_prototxt.InnerProduct(network,name="fc1",bottom_name=last_name,top_name='fc1',num_output=2,weight_type='msra',bias_type='constant') #if mode=='train': network,last_name=write_prototxt.SoftmaxWithLoss(network,name="Softmax1",bottom_name1='fc1',bottom_name2='label',top_name='Softmax1') if mode=='test': network,last_name=write_prototxt.Accuracy(network,name="prob",bottom_name1='fc1',bottom_name2='label',top_name='prob') #if mode=='deploy': #network,last_name=write_prototxt.Softmax(network,name="prob",bottom_name='fc1',top_name='prob') # print network return network
def Net(mode='train', root_path='', batch_size=32): network = 'name:"MobileNetV1"' + '\n' if mode == 'train': network, last_name = write_prototxt.data(network, name="Data1", mirror=True, crop_size=28, batch_size=batch_size, backend="LMDB", shuffle=True, datasets_path=root_path) use_global_stats = False elif mode == 'test': network, last_name = write_prototxt.data(network, name="Data1", mirror=False, crop_size=28, batch_size=batch_size, backend="LMDB", shuffle=False, datasets_path=root_path) use_global_stats = True network, last_name = write_prototxt.Convolution(network, name="conv1", bottom_name=last_name, top_name='conv1', num_output=32, bias_term=False, pad=1, kernel_size=3, stride=1, weight_type='msra', bias_type='constant') network, last_name = write_prototxt.BatchNorm( network, name_bn="conv1_bn", name_scale="conv1__scale", bottom_name="conv1", top_name="conv1", use_global_stats=use_global_stats) network, last_name = write_prototxt.ReLU(network, name="conv1_ReLU", bottom_name='conv1', top_name='conv1') network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv2_', block_n=1, num_out1=32, num_out2=64, downsampling=False, use_global_stats=use_global_stats) network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv3_', block_n=1, num_out1=64, num_out2=128, downsampling=True, use_global_stats=use_global_stats) network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv4_', block_n=1, num_out1=128, num_out2=128, downsampling=False, use_global_stats=use_global_stats) network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv5_', block_n=1, num_out1=128, num_out2=256, downsampling=False, use_global_stats=use_global_stats) network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv6_', block_n=1, num_out1=256, num_out2=512, downsampling=True, use_global_stats=use_global_stats) network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv7_', block_n=1, num_out1=512, num_out2=512, downsampling=False, use_global_stats=use_global_stats) network, last_name = Mobile_Unit(network, last_name=last_name, block_name='conv8_', block_n=1, num_out1=512, num_out2=512, downsampling=False, use_global_stats=use_global_stats) network, last_name = write_prototxt.Pooling(network, name="Pooling1", bottom_name=last_name, top_name='Pooling1', pool='AVE', global_pooling=True) network, last_name = write_prototxt.InnerProduct(network, name="fc1", bottom_name=last_name, top_name='fc1', num_output=10, weight_type='xavier', bias_type='constant') if mode == 'train': network, last_name = write_prototxt.SoftmaxWithLoss( network, name="Softmax1", bottom_name1='fc1', bottom_name2='Data2', top_name='Softmax1') if mode == 'test': network, last_name = write_prototxt.Accuracy(network, name="prob", bottom_name1='fc1', bottom_name2='Data2', top_name='prob') # # print network return network
def Net(mode='train', root_path='', batch_size=32): network = 'name:"ShuffleNet"' + '\n' if mode == 'train': network, last_name = write_prototxt.data(network, name="Data1", mirror=True, crop_size=28, batch_size=batch_size, backend="LMDB", shuffle=True, datasets_path=root_path) use_global_stats = False elif mode == 'test': network, last_name = write_prototxt.data(network, name="Data1", mirror=False, crop_size=28, batch_size=batch_size, backend="LMDB", shuffle=False, datasets_path=root_path) use_global_stats = True network, last_name = write_prototxt.Convolution(network, name="conv1", bottom_name=last_name, top_name='conv1', num_output=15, bias_term=False, pad=1, kernel_size=3, stride=1, weight_type='msra', bias_type='constant') network, last_name = write_prototxt.BatchNorm( network, name_bn="conv1_bn", name_scale="conv1__scale", bottom_name="conv1", top_name="conv1", use_global_stats=use_global_stats) network, last_name = write_prototxt.ReLU(network, name="conv1_ReLU", bottom_name='conv1', top_name='conv1') network, last_name = ShuffleNet_Unit0(network, last_name=last_name, block_name='resx1_conv', block_n=1, num_out0=24, num_out1=45, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx2_conv', block_n=1, num_out0=30, num_out1=60, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx3_conv', block_n=1, num_out0=30, num_out1=60, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx4_conv', block_n=1, num_out0=30, num_out1=60, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx5_conv', block_n=1, num_out0=30, num_out1=60, downsampling=True, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx6_conv', block_n=1, num_out0=48, num_out1=120, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx7_conv', block_n=1, num_out0=48, num_out1=120, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx10_conv', block_n=1, num_out0=48, num_out1=120, downsampling=True, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx11_conv', block_n=1, num_out0=60, num_out1=240, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx12_conv', block_n=1, num_out0=60, num_out1=240, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = ShuffleNet_Unit(network, last_name=last_name, block_name='resx13_conv', block_n=1, num_out0=60, num_out1=240, downsampling=False, group=3, use_global_stats=use_global_stats) network, last_name = write_prototxt.Pooling(network, name="Pooling1", bottom_name=last_name, top_name='Pooling1', pool='AVE', global_pooling=True) network, last_name = write_prototxt.InnerProduct(network, name="fc1", bottom_name=last_name, top_name='fc1', num_output=10, weight_type='xavier', bias_type='constant') if mode == 'train': network, last_name = write_prototxt.SoftmaxWithLoss( network, name="Softmax1", bottom_name1='fc1', bottom_name2='Data2', top_name='Softmax1') if mode == 'test': network, last_name = write_prototxt.Accuracy(network, name="prob", bottom_name1='fc1', bottom_name2='Data2', top_name='prob') # # print network return network