def create_network(): ''' Define 3D convolutional network ''' # Define for weight initialization g1 = GaussianInit(mean=0., var=0.01) g5 = GaussianInit(mean=0., var=0.005) c0 = ConstantInit(val=0.) c1 = ConstantInit(val=1.) ax.Y.length = 101 padding = {'D': 1, 'H': 1, 'W': 1, 'C': 0} strides = {'D': 2, 'H': 2, 'W': 2, 'C': 1} layers = [ Convolution((3, 3, 3, 64), padding=padding, filter_init=g1, bias_init=c0, activation=Rectlin()), Pooling((1, 2, 2), strides={ 'D': 1, 'H': 2, 'W': 2, 'C': 1 }), Convolution((3, 3, 3, 128), padding=padding, filter_init=g1, bias_init=c1, activation=Rectlin()), Pooling((2, 2, 2), strides=strides), Convolution((3, 3, 3, 256), padding=padding, filter_init=g1, bias_init=c1, activation=Rectlin()), Pooling((2, 2, 2), strides=strides), Convolution((3, 3, 3, 256), padding=padding, filter_init=g1, bias_init=c1, activation=Rectlin()), Pooling((2, 2, 2), strides=strides), Convolution((3, 3, 3, 256), padding=padding, filter_init=g1, bias_init=c1, activation=Rectlin()), Pooling((2, 2, 2), strides=strides), Affine(nout=2048, weight_init=g5, bias_init=c1, activation=Rectlin()), Dropout(keep=0.5), Affine(nout=2048, weight_init=g5, bias_init=c1, activation=Rectlin()), Dropout(keep=0.5), Affine(axes=ax.Y, weight_init=g1, bias_init=c0, activation=Softmax()) ] return Sequential(layers)
def __init__(self, branch_units=[(192, 320), (192, 192, 192, 192)], name=None): """ Fourth inception block with three branches, concatenated in the end 1. 1x1 conv, 3x3 conv (stride=2, valid) 2. 1x1 conv, 1x7 conv, 7x1 conv, 3x3 conv (stride=2, valid) 3. 3x3 pool (stride=2, valid) Convolution(H, W, K) : height, width, number of filters Mixed_7a layer """ (p1, p2) = branch_units branch1 = Sequential([ Convolution(name=name + '_br1_conv1x1', **conv_params(filter_shape=(1, 1, p1[0]))), Convolution(name=name + '_br1_conv3x3', **conv_params(filter_shape=(3, 3, p1[1]), strides=2, padding=0)) ]) branch2 = Sequential([ Convolution(name=name + '_br2_conv1x1', **conv_params(filter_shape=(1, 1, p2[0]))), Convolution(name=name + '_br2_conv1x7', **conv_params(filter_shape=(1, 7, p2[1]), padding={ 'H': 0, 'W': 3, 'D': 0 })), Convolution(name=name + '_br2_conv7x1', **conv_params(filter_shape=(7, 1, p2[2]), padding={ 'H': 3, 'W': 0, 'D': 0 })), Convolution(name=name + '_br2_conv3x3', **conv_params(filter_shape=(3, 3, p2[3]), strides=2, padding=0)) ]) branch3 = Pooling(name=name + '_br3_maxpool', pool_shape=(3, 3), padding=0, strides=2, pool_type="max") branches = [branch1, branch2, branch3] super(Inceptionv3_b4, self).__init__(name=name, branches=branches, mode='concat')
def __init__(self, branch_units=[(64, ), (48, 64), (64, 96, 96), (64, )], name=None): """ First inception block with four branches, concatenated in the end 1. 1x1 conv 2. 1x1 conv, 5x5 conv 3. 1x1 conv, 3x3conv, 3x3 conv 4. 3x3 pool, 1x1 conv Convolution(H, W, K) : height, width, number of filters Mixed_5b, Mixed_5c, Mixed_5d layers """ (p1, p2, p3, p4) = branch_units branch1 = Convolution(name=name + '_br1_1x1conv', **conv_params(filter_shape=(1, 1, p1[0]))) branch2 = Sequential([ Convolution(name=name + '_br2_1x1conv', **conv_params(filter_shape=(1, 1, p2[0]))), Convolution(name=name + '_br2_5x5conv', **conv_params(filter_shape=(5, 5, p2[1]), padding=2)) ]) branch3 = Sequential([ Convolution(name=name + '_br3_1x1conv', **conv_params(filter_shape=(1, 1, p3[0]))), Convolution(name=name + '_br3_3x3conv1', **conv_params(filter_shape=(3, 3, p3[1]), padding=1)), Convolution(name=name + '_br3_3x3conv2', **conv_params(filter_shape=(3, 3, p3[2]), padding=1)) ]) branch4 = Sequential([ Pooling(name=name + '_br4_avgpool', pool_shape=(3, 3), padding=1, strides=1, pool_type="avg"), Convolution(name=name + '_br4_conv1x1', **conv_params(filter_shape=(1, 1, p4[0]))) ]) branches = [branch1, branch2, branch3, branch4] super(Inceptionv3_b1, self).__init__(name=name, branches=branches, mode='concat')
def __init__(self, inputs, dataset, stage_depth, batch_norm=False, activation=False, preprocess=False): nfms = [ 2**(stage + 4) for stage in sorted(list(range(3)) * stage_depth) ] strides = [ 1 if cur == prev else 2 for cur, prev in zip(nfms[1:], nfms[:-1]) ] layers = [] if preprocess and dataset == 'cifar10': layers = Preprocess(functor=cifar_mean_subtract) layers.append(Convolution(**conv_params(3, 16, batch_norm=batch_norm))) layers.append(f_module(nfms[0], first=True, batch_norm=batch_norm)) for nfm, stride in zip(nfms[1:], strides): layers.append(f_module(nfm, strides=stride, batch_norm=batch_norm)) if batch_norm: layers.append(BatchNorm()) if activation: layers.append(Activation(Rectlin())) layers.append(Pooling((8, 8), strides=2, pool_type='avg')) if dataset == 'cifar10': ax.Y.length = 10 layers.append( Affine(axes=ax.Y, weight_init=KaimingInit(), batch_norm=batch_norm, activation=Softmax())) elif dataset == 'i1k': ax.Y.length = 1000 layers.append( Affine(axes=ax.Y, weight_init=KaimingInit(), batch_norm=batch_norm, activation=Softmax())) else: raise ValueError("Incorrect dataset provided") super(mini_residual_network, self).__init__(layers=layers)
def __init__(self, stage_depth): nfms = [2**(stage + 4) for stage in sorted(list(range(3)) * stage_depth)] print(nfms) strides = [1 if cur == prev else 2 for cur, prev in zip(nfms[1:], nfms[:-1])] layers = [Preprocess(functor=cifar_mean_subtract), Convolution(**conv_params(3, 16)), f_module(nfms[0], first=True)] for nfm, stride in zip(nfms[1:], strides): layers.append(f_module(nfm, strides=stride)) layers.append(BatchNorm()) layers.append(Activation(Rectlin())) layers.append(Pooling((8, 8), pool_type='avg')) layers.append(Affine(axes=ax.Y, weight_init=KaimingInit(), activation=Softmax())) super(residual_network, self).__init__(layers=layers)
def make_layers(use_large, vocab_size): if use_large: init = GaussianInit(0., 0.02) else: init = GaussianInit(0., 0.05) layers = [] layers.append(make_embedding_layer(vocab_size)) layers.append(lambda op: ng.map_roles(op, {'REC': 'W', 'F': 'C'})) kernel_sizes = [7, 7, 3, 3, 3, 3] pool_layer_idxs = [0, 1, 5] conv_nout = 1024 if use_large else 256 fc_nout = 2048 if use_large else 1024 for i in range(6): conv_layer = Convolution( **conv_params(kernel_sizes[i], conv_nout, init)) layers.append(conv_layer) if i in pool_layer_idxs: pool_layer = Pooling(pool_shape=(3, ), strides=3) layers.append(pool_layer) layers.append( Affine(nout=fc_nout, weight_init=init, bias_init=ConstantInit(0.), activation=Rectlin())) layers.append(Dropout(keep=0.5)) layers.append( Affine(nout=fc_nout, weight_init=init, bias_init=ConstantInit(0.), activation=Rectlin())) layers.append(Dropout(keep=0.5)) layers.append( Affine(axes=(ax.Y, ), weight_init=init, bias_init=ConstantInit(0.), activation=Softmax())) return layers
def __init__(self, branch_units, activation=Rectlin(), bias_init=UniformInit(low=-0.08, high=0.08), filter_init=XavierInit()): (p1, p2, p3, p4) = branch_units self.branch_1 = Convolution((1, 1, p1[0]), activation=activation, bias_init=bias_init, filter_init=filter_init) self.branch_2 = [ Convolution((1, 1, p2[0]), activation=activation, bias_init=bias_init, filter_init=filter_init), Convolution((3, 3, p2[1]), activation=activation, bias_init=bias_init, filter_init=filter_init, padding=1) ] self.branch_3 = [ Convolution((1, 1, p3[0]), activation=activation, bias_init=bias_init, filter_init=filter_init), Convolution((5, 5, p3[1]), activation=activation, bias_init=bias_init, filter_init=filter_init, padding=2) ] self.branch_4 = [ Pooling(pool_shape=(3, 3), padding=1, strides=1, pool_type="max"), Convolution((1, 1, p3[0]), activation=activation, bias_init=bias_init, filter_init=filter_init) ]
def __init__(self, branch_units=[(384, ), (64, 96, 96)], name=None): """ Second inception block with three branches, concatenated in the end 1. 3x3 conv (stride = 2, valid) 2. 1x1 conv, 3x3 conv, 3x3 conv (stride=2, valid) 3. 3x3 pool (stride = 2, valid) Convolution(H, W, K) : height, width, number of filters Mixed_6a layer """ (p1, p2) = branch_units branch1 = Convolution(name=name + '_br1_3x3conv', **conv_params(filter_shape=(3, 3, p1[0]), strides=2, padding=0)) branch2 = Sequential([ Convolution(name=name + '_br2_1x1conv', **conv_params(filter_shape=(1, 1, p2[0]))), Convolution(name=name + '_br2_3x3conv1', **conv_params(filter_shape=(3, 3, p2[1]), padding=1)), Convolution(name=name + '_br2_3x3conv2', **conv_params(filter_shape=(3, 3, p2[2]), strides=2, padding=0)) ]) branch3 = Pooling(pool_shape=(3, 3), padding=0, strides=2, pool_type="max", name=name + '_br3_maxpool') branches = [branch1, branch2, branch3] super(Inceptionv3_b2, self).__init__(name=name, branches=branches, mode='concat')
def __init__(self, net_type, resnet_size, bottleneck, num_resnet_mods): # For CIFAR10 dataset if net_type == 'cifar10': # Number of Filters num_fils = [16, 32, 64] # Network Layers layers = [ # Subtracting mean as suggested in paper Preprocess(functor=cifar10_mean_subtract), # First Conv with 3x3 and stride=1 Convolution(**conv_params(3, 16)) ] first_resmod = True # Indicates the first residual module # Loop 3 times for each filter. for fil in range(3): # Lay out n residual modules so that we have 2n layers. for resmods in range(num_resnet_mods): if (resmods == 0): if (first_resmod): # Strides=1 and Convolution side path main_path, side_path = self.get_mp_sp( num_fils[fil], net_type, direct=False) layers.append(ResidualModule(main_path, side_path)) layers.append(Activation(Rectlin())) first_resmod = False else: # Strides=2 and Convolution side path main_path, side_path = self.get_mp_sp( num_fils[fil], net_type, direct=False, strides=2) layers.append(ResidualModule(main_path, side_path)) layers.append(Activation(Rectlin())) else: # Strides=1 and direct connection main_path, side_path = self.get_mp_sp( num_fils[fil], net_type) layers.append(ResidualModule(main_path, side_path)) layers.append(Activation(Rectlin())) # Do average pooling --> fully connected--> softmax. layers.append(Pooling([8, 8], pool_type='avg')) layers.append( Affine(axes=ax.Y, weight_init=KaimingInit(), batch_norm=True)) layers.append(Activation(Softmax())) # For I1K dataset elif net_type == "i1k": # Number of Filters num_fils = [64, 128, 256, 512] # Number of residual modules we need to instantiate at each level num_resnet_mods = num_i1k_resmods(resnet_size) # Network layers layers = [ # Subtracting mean Preprocess(functor=i1k_mean_subtract), # First Conv layer Convolution((7, 7, 64), strides=2, padding=3, batch_norm=True, activation=Rectlin(), filter_init=KaimingInit()), # Max Pooling Pooling([3, 3], strides=2, pool_type='max', padding=1) ] first_resmod = True # Indicates the first residual module for which strides are 1 # Loop 4 times for each filter for fil in range(4): # Lay out residual modules as in num_resnet_mods list for resmods in range(num_resnet_mods[fil]): if (resmods == 0): if (first_resmod): # Strides=1 and Convolution Side path main_path, side_path = self.get_mp_sp( num_fils[fil], net_type, direct=False, bottleneck=bottleneck) layers.append(ResidualModule(main_path, side_path)) layers.append(Activation(Rectlin())) first_resmod = False else: # Strides=2 and Convolution side path main_path, side_path = self.get_mp_sp( num_fils[fil], net_type, direct=False, bottleneck=bottleneck, strides=2) layers.append(ResidualModule(main_path, side_path)) layers.append(Activation(Rectlin())) else: # Strides=1 and direct connection main_path, side_path = self.get_mp_sp( num_fils[fil], net_type, bottleneck=bottleneck) layers.append(ResidualModule(main_path, side_path)) layers.append(Activation(Rectlin())) # Do average pooling --> fully connected--> softmax. layers.append(Pooling([7, 7], pool_type='avg')) layers.append( Affine(axes=ax.Y, weight_init=KaimingInit(), batch_norm=True)) layers.append(Activation(Softmax())) else: raise NameError( "Incorrect dataset. Should be --dataset cifar10 or --dataset i1k" ) super(BuildResnet, self).__init__(layers=layers)
def __init__(self, mini=False): """ Builds Inception model based on: https://github.com/tensorflow/models/blob/master/research/slim/nets/inception_v3.py """ # Input size is 299 x 299 x 3 if mini: """ This is the mini model with reduced number of filters in each layer """ # Root branch of the tree seq1 = Sequential([ Convolution(name='conv_1a_3x3', **conv_params(filter_shape=(3, 3, 32), padding=0, strides=2)), # conv2d_1a_3x3 Convolution(name='conv_2a_3x3', **conv_params(filter_shape=(3, 3, 16), padding=0)), # conv2d_2a_3x3 Convolution(name='conv_2b_3x3', **conv_params(filter_shape=(3, 3, 16), padding=1)), # conv2d_2b_3x3 Pooling(name='pool_1_3x3', pool_shape=(3, 3), padding=0, strides=2, pool_type='max'), # maxpool_3a_3x3 Convolution(name='conv_3b_1x1', **conv_params(filter_shape=(1, 1, 16))), # conv2d_3b_1x1 Convolution(name='conv_4a_3x3', **conv_params(filter_shape=(3, 3, 32), padding=1)), # conv2d_4a_3x3 Pooling(name='pool_2_3x3', pool_shape=(3, 3), padding=0, strides=2, pool_type='max'), # maxpool_5a_3x3 Inceptionv3_b1([(32, ), (32, 32), (32, 32, 32), (32, )], name='mixed_5b'), Inceptionv3_b1([(32, ), (32, 32), (32, 32, 32), (32, )], name='mixed_5c'), Inceptionv3_b1([(32, ), (32, 32), (32, 32, 32), (32, )], name=' mixed_5d'), Inceptionv3_b2([(32, ), (32, 32, 32)], name=' mixed_6a'), Inceptionv3_b3([(32, ), (32, 32, 32), (32, 32, 32, 32, 32), (32, )], name='mixed_6b'), Inceptionv3_b3([(32, ), (32, 32, 32), (32, 32, 32, 32, 32), (32, )], name='mixed_6c'), Inceptionv3_b3([(32, ), (32, 32, 32), (32, 32, 32, 32, 32), (32, )], name='mixed_6d'), Inceptionv3_b3([(32, ), (32, 32, 32), (32, 32, 32, 32, 32), (32, )], name='mixed_6e') ]) # Branch of main classifier seq2 = Sequential([ Inceptionv3_b4([(32, 32), (32, 32, 32, 32)], name='mixed_7a'), Inceptionv3_b5([(32, ), (32, 32, 32), (32, 32, 32, 32), (32, )], name='mixed_7b'), Inceptionv3_b5([(32, ), (32, 32, 32), (32, 32, 32, 32), (32, )], name='mixed_7c'), Pooling(pool_shape=(8, 8), padding=0, strides=2, pool_type='avg'), # Last Avg Pool Dropout(keep=0.8), Convolution(name='main_final_conv1x1', **conv_params(filter_shape=(1, 1, 1000), activation=Softmax(), batch_norm=False)) ]) # Auxiliary classifier seq_aux = Sequential([ Pooling(pool_shape=(5, 5), padding=0, strides=3, pool_type='avg'), Convolution(name='aux_conv1x1_v1', **conv_params(filter_shape=(1, 1, 32))), Convolution(name='aux_conv5x5', **conv_params(filter_shape=(5, 5, 32))), Convolution(name='aux_conv1x1_v2', **conv_params(filter_shape=(1, 1, 1000), activation=Softmax(), batch_norm=False)) ]) else: # Root branch of the tree seq1 = Sequential([ Convolution(name='conv_1a_3x3', **conv_params(filter_shape=(3, 3, 32), padding=0, strides=2)), # conv2d_1a_3x3 Convolution(name='conv_2a_3x3', **conv_params(filter_shape=(3, 3, 32), padding=0)), # conv2d_2a_3x3 Convolution(name='conv_2b_3x3', **conv_params(filter_shape=(3, 3, 64), padding=1)), # conv2d_2b_3x3 Pooling(name='pool_1_3x3', pool_shape=(3, 3), padding=0, strides=2, pool_type='max'), # maxpool_3a_3x3 Convolution(name='conv_3b_1x1', **conv_params(filter_shape=(1, 1, 80))), # conv2d_3b_1x1 Convolution(name='conv_4a_3x3', **conv_params(filter_shape=(3, 3, 192), padding=1)), # conv2d_4a_3x3 Pooling(name='pool_2_3x3', pool_shape=(3, 3), padding=0, strides=2, pool_type='max'), # maxpool_5a_3x3 Inceptionv3_b1([(64, ), (48, 64), (64, 96, 96), (32, )], name='mixed_5b'), Inceptionv3_b1([(64, ), (48, 64), (64, 96, 96), (64, )], name='mixed_5c'), Inceptionv3_b1([(64, ), (48, 64), (64, 96, 96), (64, )], name=' mixed_5d'), Inceptionv3_b2([(384, ), (64, 96, 96)], name=' mixed_6a'), Inceptionv3_b3([(192, ), (128, 128, 192), (128, 128, 128, 128, 192), (192, )], name='mixed_6b'), Inceptionv3_b3([(192, ), (160, 160, 192), (160, 160, 160, 160, 192), (192, )], name='mixed_6c'), Inceptionv3_b3([(192, ), (160, 160, 192), (160, 160, 160, 160, 192), (192, )], name='mixed_6d'), Inceptionv3_b3([(192, ), (192, 192, 192), (192, 192, 192, 192, 192), (192, )], name='mixed_6e') ]) # Branch of main classifier seq2 = [ Inceptionv3_b4([(192, 320), (192, 192, 192, 192)], name='mixed_7a'), Inceptionv3_b5([(320, ), (384, 384, 384), (448, 384, 384, 384), (192, )], name='mixed_7b'), Inceptionv3_b5([(320, ), (384, 384, 384), (448, 384, 384, 384), (192, )], name='mixed_7c'), Pooling(pool_shape=(8, 8), padding=0, strides=2, pool_type='avg'), # Last Avg Pool Dropout(keep=0.8), Convolution(name='main_final_conv1x1', **conv_params(filter_shape=(1, 1, 1000), activation=Softmax(), batch_norm=False)) ] seq2 = Sequential(seq2) # Auxiliary classifier my_seq = [ Pooling(pool_shape=(5, 5), padding=0, strides=3, pool_type='avg'), Convolution(name='aux_conv1x1_v1', **conv_params(filter_shape=(1, 1, 128))), Convolution(name='aux_conv5x5', **conv_params(filter_shape=(5, 5, 768))), Convolution(name='aux_conv1x1_v2', **conv_params(filter_shape=(1, 1, 1000), activation=Softmax(), batch_norm=False)) ] seq_aux = Sequential(my_seq) self.seq1 = seq1 self.seq2 = seq2 self.seq_aux = seq_aux
def __init__(self, branch_units=[(320, ), (384, 384, 384), (448, 384, 384, 384), (192, )], name=None): """ Fifth inception block with four branches, concatenated in the end 1. 1x1 conv 2. 1x1 conv, followed by two sub-branches [1x3 conv, 3x1 conv] 3. 1x1 conv, 3x3 conv, followed by two sub-branches [1x3 conv, 3x1 conv] 4. 3x3 pool, 1x1 conv Convolution(H, W, K) : height, width, number of filters Mixed_7b, Mixed_7c layers """ (p1, p2, p3, p4) = branch_units # Branch 1 branch1 = Convolution(name=name + '_br1_conv1x1', **conv_params(filter_shape=(1, 1, p1[0]))) # Branch 2 branch2a1_params = conv_params(filter_shape=(1, 3, p2[1]), padding={ 'H': 0, 'W': 1, 'D': 0 }) branch2a2_params = conv_params(filter_shape=(3, 1, p2[2]), padding={ 'H': 1, 'W': 0, 'D': 0 }) # This is the sub-branch with two parallel branches of 1x3 and 3x1 branch2a = Parallel([ Convolution(name=name + '_br2a_conv1x3', **branch2a1_params), Convolution(name=name + '_br2a_conv3x1', **branch2a2_params) ]) branch2 = Sequential([ Convolution(name=name + '_br2_conv1x1', **conv_params(filter_shape=(1, 1, p2[0]))), branch2a ]) # Branch 3 branch3a1_params = conv_params(filter_shape=(1, 3, p3[2]), padding={ 'H': 0, 'W': 1, 'D': 0 }) branch3a2_params = conv_params(filter_shape=(3, 1, p3[3]), padding={ 'H': 1, 'W': 0, 'D': 0 }) branch3a = Parallel([ Convolution(name=name + '_br3_conv1x3', **branch3a1_params), Convolution(name=name + '_br3_conv3x1', **branch3a2_params) ]) branch3 = Sequential([ Convolution(name=name + '_br3_conv1x1', **conv_params(filter_shape=(1, 1, p3[0]))), Convolution(name=name + '_br3_conv3x3', **conv_params(filter_shape=(3, 3, p3[1]), padding=1)), branch3a ]) # Branch 4 branch4 = Sequential([ Pooling(name=name + '_br4_avgpool', pool_shape=(3, 3), padding=1, strides=1, pool_type="avg"), Convolution(name=name + '_br4_conv1x1', **conv_params(filter_shape=(1, 1, p4[0]))) ]) # Combine branches branches = [branch1, branch2, branch3, branch4] super(Inceptionv3_b5, self).__init__(name=name, branches=branches, mode='concat')
def __init__(self, branch_units=[(192), (160, 160, 192), (160, 160, 160, 160, 192), (192, )], name=None): """ Third inception block with four branches, concatenated in the end 1. 1x1 conv 2. 1x1 conv, 1x7 conv, 7x1 conv 3. 1x1 conv, 7x1 conv, 1x7 conv, 7x1 conv, 1x7 conv 4. 3x3 pool, 1x1 conv Convolution(H, W, K) : height, width, number of filters Mixed_6b, Mixed_6c, Mixed_6c, Mixed_6d, Mixed_6e layers """ (p1, p2, p3, p4) = branch_units branch1 = Convolution(name=name + '_br1_1x1conv', **conv_params(filter_shape=(1, 1, p1[0]))) branch2 = Sequential([ Convolution(name=name + '_br2_1x1conv', **conv_params(filter_shape=(1, 1, p2[0]))), Convolution(name=name + '_br2_1x7conv', **conv_params(filter_shape=(1, 7, p2[1]), padding={ 'H': 0, 'W': 3, 'D': 0 })), Convolution(name=name + '_br27x1conv', **conv_params(filter_shape=(7, 1, p2[2]), padding={ 'H': 3, 'W': 0, 'D': 0 })) ]) branch3 = Sequential([ Convolution(name=name + '_br3_1x1conv', **conv_params(filter_shape=(1, 1, p3[0]))), Convolution(name=name + '_br3_7x1conv1', **conv_params(filter_shape=(7, 1, p3[1]), padding={ 'H': 3, 'W': 0, 'D': 0 })), Convolution(name=name + '_br3_1x7conv1', **conv_params(filter_shape=(1, 7, p3[2]), padding={ 'H': 0, 'W': 3, 'D': 0 })), Convolution(name=name + '_br3_7x1conv2', **conv_params(filter_shape=(7, 1, p3[3]), padding={ 'H': 3, 'W': 0, 'D': 0 })), Convolution(name=name + '_br3_1x7conv2', **conv_params(filter_shape=(1, 7, p3[4]), padding={ 'H': 0, 'W': 3, 'D': 0 })) ]) branch4 = Sequential([ Pooling(name=name + '_br4_avgpool', pool_shape=(3, 3), padding=1, strides=1, pool_type="avg"), Convolution(name=name + '_br4_1x1conv', **conv_params(filter_shape=(1, 1, p4[0]))) ]) branches = [branch1, branch2, branch3, branch4] super(Inceptionv3_b3, self).__init__(name=name, branches=branches, mode='concat')
batch_size=args.batch_size, total_iterations=args.num_iterations) inputs = train_set.make_placeholders(include_iteration=True) ax.Y.length = 1000 # number of outputs of last layer. # weight initialization init = UniformInit(low=-0.08, high=0.08) # Setup model seq1 = Sequential([ Convolution((3, 3, 64), filter_init=GaussianInit(std=0.01), bias_init=init, activation=Rectlin(), padding=1), Pooling((2, 2), strides=2), Convolution((3, 3, 128), filter_init=GaussianInit(std=0.01), bias_init=init, activation=Rectlin(), padding=1), Pooling((2, 2), strides=2), Convolution((3, 3, 256), filter_init=GaussianInit(std=0.01), bias_init=init, activation=Rectlin(), padding=1), Convolution((3, 3, 256), filter_init=GaussianInit(std=0.01), bias_init=init, activation=Rectlin(),
total_iterations=args.num_iterations) inputs = train_set.make_placeholders(include_iteration=True) ax.Y.length = 1000 # number of outputs of last layer. # weight initialization init = UniformInit(low=-0.08, high=0.08) # Setup model seq1 = Sequential([ Convolution((11, 11, 64), filter_init=GaussianInit(var=0.01), bias_init=init, activation=Rectlin(), padding=3, strides=4), Pooling((3, 3), strides=2), Convolution((5, 5, 192), filter_init=GaussianInit(var=0.01), bias_init=init, activation=Rectlin(), padding=2), Pooling((3, 3), strides=2), Convolution((3, 3, 384), filter_init=GaussianInit(var=0.03), bias_init=init, activation=Rectlin(), padding=1), Convolution((3, 3, 256), filter_init=GaussianInit(var=0.03), bias_init=init, activation=Rectlin(),
outputs = [ branch_1_output, branch_2_output, branch_3_output, branch_4_output ] # This does the equivalent of neon's merge-broadcast return ng.concat_along_axis(outputs, branch_1_output.axes.channel_axis()) seq1 = Sequential([ Convolution((7, 7, 64), padding=3, strides=2, activation=Rectlin(), bias_init=bias_init, filter_init=XavierInit()), Pooling(pool_shape=(3, 3), padding=1, strides=2, pool_type='max'), Convolution((1, 1, 64), activation=Rectlin(), bias_init=bias_init, filter_init=XavierInit()), Convolution((3, 3, 192), activation=Rectlin(), bias_init=bias_init, filter_init=XavierInit(), padding=1), Pooling(pool_shape=(3, 3), padding=1, strides=2, pool_type='max'), Inception([(64, ), (96, 128), (16, 32), (32, )]), Inception([(128, ), (128, 192), (32, 96), (64, )]), Pooling(pool_shape=(3, 3), padding=1, strides=2, pool_type='max'), Inception([(192, ), (96, 208), (16, 48), (64, )]), Inception([(160, ), (112, 224), (24, 64), (64, )]),