def __init__(self) -> None: size = img_size self.conv1 = convolution.Convolution(input_shape=(size, size, ci), out_channel=oc1, kernel_size=(ks1, ks1), stride=(stride1, stride1), learning_rate=conv1_learning_rate, activate_func='relu') assert (size - ks1) % stride1 == 0 size = (size - ks1) // stride1 + 1 self.pool1 = pooling.Pooling(input_shape=(size, size, oc1), pool_size=ps1) assert size % 2 == 0 size //= 2 self.conv2 = convolution.Convolution(input_shape=(size, size, oc1), out_channel=oc2, kernel_size=(ks2, ks2), stride=(stride2, stride2), learning_rate=conv2_learning_rate, activate_func='relu') assert (size - ks2) % stride2 == 0 size = (size - ks2) // stride2 + 1 self.pool2 = pooling.Pooling(input_shape=(size, size, oc2), pool_size=ps2) assert size % 2 == 0 size //= 2 self.conv3 = convolution.Convolution(input_shape=(size, size, oc2), out_channel=oc3, kernel_size=(ks3, ks3), stride=(stride3, stride3), learning_rate=conv3_learning_rate, activate_func='relu') assert (size - ks3) % stride3 == 0 size = (size - ks3) // stride3 + 1 self.pool3 = pooling.Pooling(input_shape=(size, size, oc3), pool_size=ps3) assert size % 2 == 0 size //= 2 self.conv4 = convolution.Convolution(input_shape=(size, size, oc3), out_channel=oc4, kernel_size=(ks4, ks4), stride=(stride4, stride4), learning_rate=conv4_learning_rate, activate_func='relu') assert (size - ks4) % stride4 == 0 size4 = (size - ks4) // stride4 + 1 self.fc1 = full_connection.FullConnection( dim_in=size * size * oc3, dim_out=deepid_dim // 2, learning_rate=fc1_learning_rate, activate_func='relu') self.fc2 = full_connection.FullConnection( dim_in=size4 * size4 * oc4, dim_out=deepid_dim // 2, learning_rate=fc2_learning_rate, activate_func='relu')
def _layers_init(self): return sequential.Sequential([ convolution.Convolution(kernel_size=4, output_depth=32, input_depth=4, input_dim=27, act='relu', stride_size=1, pad='VALID'), convolution.Convolution(kernel_size=3, output_depth=32, stride_size=1, act='relu', pad='SAME'), maxpool.MaxPool(), convolution.Convolution(kernel_size=3, output_depth=64, stride_size=1, act='relu', pad='SAME'), convolution.Convolution(kernel_size=3, output_depth=64, stride_size=1, act='relu', pad='SAME'), convolution.Convolution(kernel_size=3, output_depth=64, stride_size=1, act='relu', pad='SAME'), maxpool.MaxPool(), linear.Linear(64, act='relu', keep_prob=self.dropout_prob, use_dropout=True), linear.Linear(64, act='relu', keep_prob=self.dropout_prob, use_dropout=True), avgCyclicPool2.CyclicAvgPool(), linear.Linear(2, act='linear') ])
def convolutional(X, channel_in, channel_out, filter_height=3, filter_width=3, stride=1, pad=1): W = Parameter( np.random.randn(channel_out, channel_in, filter_height, filter_width), 'Weights') b = Parameter(np.random.randn(channel_out), 'Bias') return convolution.Convolution(X, W, b, stride, pad)
def __init__(self) -> None: self.conv1 = convolution.Convolution((130, 130, 3), out_channel=96, kernel_size=(5, 5), stride=(1, 1), learning_rate=learning_rate, padding=(1, 1), activate_func='mfm') self.conv2a = convolution.Convolution((64, 64, 48), out_channel=96, kernel_size=(1, 1), stride=(1, 1), learning_rate=learning_rate, activate_func='mfm') self.conv2 = convolution.Convolution((64, 64, 48), out_channel=192, kernel_size=(3, 3), stride=(1, 1), learning_rate=learning_rate, padding=(1, 1), activate_func='mfm') self.conv3a = convolution.Convolution((32, 32, 96), out_channel=192, kernel_size=(1, 1), stride=(1, 1), learning_rate=learning_rate, activate_func='mfm') self.conv3 = convolution.Convolution((32, 32, 96), out_channel=384, kernel_size=(3, 3), stride=(1, 1), learning_rate=learning_rate, padding=(1, 1), activate_func='mfm') self.conv4a = convolution.Convolution((16, 16, 192), out_channel=384, kernel_size=(1, 1), stride=(1, 1), learning_rate=learning_rate, activate_func='mfm') self.conv4 = convolution.Convolution((16, 16, 192), out_channel=256, kernel_size=(3, 3), stride=(1, 1), learning_rate=learning_rate, padding=(1, 1), activate_func='mfm') self.conv5a = convolution.Convolution((16, 16, 128), out_channel=256, kernel_size=(1, 1), stride=(1, 1), learning_rate=learning_rate, activate_func='mfm') self.conv5 = convolution.Convolution((16, 16, 128), out_channel=256, kernel_size=(3, 3), stride=(1, 1), learning_rate=learning_rate, padding=(1, 1), activate_func='mfm') self.pool1 = pooling.Pooling((128, 128, 48), pool_size=2) self.pool2 = pooling.Pooling((64, 64, 96), pool_size=2) self.pool3 = pooling.Pooling((32, 32, 192), pool_size=2) self.pool4 = pooling.Pooling((16, 16, 128), pool_size=2) self.fc1 = full_connection.FullConnection(8 * 8 * 128, 512, learning_rate=learning_rate, activate_func='mfm') self.fc_out = full_connection.FullConnection( 256, class_num, learning_rate=learning_rate)