Ejemplo n.º 1
0
 def __init__(
         self,
         input_shape,  #(batch_size, input_size)
         latent_dim=2,
         epoch=5,
         units=1000,
         pre=None,
         dec=None,
         lr_ch=(5, 1.1),
         modeldir='model',
         outdir='result',
         cmap=plt.get_cmap('viridis'),
 ):
     self.input_shape = input_shape
     self.latent_dim = latent_dim
     self.epoch = epoch
     self.lr_ch = lr_ch
     self.shot = epoch // lr_ch[0]
     self.modeldir = modeldir
     self.outdir = outdir
     if not pre:
         pre = rm.Sequential([rm.Dense(units), rm.Relu()])
         enc = Enc(pre, latent_dim)
     if not dec:
         dec = rm.Sequential([
             rm.Dense(units),
             rm.Relu(),
             rm.Dense(input_shape[-1]),
             rm.Sigmoid()
         ])
     self.ae = VAE(enc, dec, latent_dim)
     self.cmap = cmap
Ejemplo n.º 2
0
    def __init__(self, num_class):
        self.base1 = rm.Sequential([
            InceptionV2Stem(),
            InceptionV2BlockA([64, 48, 64, 64, 96, 32]),
            InceptionV2BlockA(),
            InceptionV2BlockA(),
            InceptionV2BlockB(),
            InceptionV2BlockC([192, 128, 192, 128, 192, 192]),
            InceptionV2BlockC(),
            InceptionV2BlockC(),
            InceptionV2BlockC()])
        self.aux1 = rm.Sequential([
            rm.AveragePool2d(filter=5, stride=3),
            rm.Conv2d(128, filter=1),
            rm.Relu(),
            rm.Conv2d(768, filter=1),
            rm.Relu(),
            rm.Flatten(),
            rm.Dense(num_class)])

        self.base2 = rm.Sequential([
            InceptionV2BlockD(),
            InceptionV2BlockE(),
            InceptionV2BlockE(),
            rm.AveragePool2d(filter=8),
            rm.Flatten()])

        self.aux2 = rm.Dense(num_class)
Ejemplo n.º 3
0
def test_ddpg(agent, environ, fit_args, use_gpu):
    cuda.set_cuda_active(True)
    action_shape = (1,)
    state_shape = (2,)
    env = environ(action_shape, state_shape)
    actor_network = rm.Sequential([
        rm.Dense(5),
        rm.Dense(action_shape[0]),
    ])

    class Critic(rm.Model):
        def __init__(self):
            self._l1 = rm.Dense(5)
            self._l2 = rm.Dense(1)

        def forward(self, x, action):
            return self._l2(rm.concat(self._l1(x), action))

    critic_network = Critic()
    model = agent(env, actor_network, critic_network)
    action = model.action(np.random.rand(*state_shape))

    assert action.shape == action_shape

    # Check fit
    model.fit(epoch=1, epoch_step=10, batch_size=4, random_step=20, test_step=10, **fit_args)
    print(model.history)
 def __init__(self,
              input_shape,
              output_shape,
              units=10,
              depth=3,
              growth_rate=12,
              dropout=False,
              initializer=rm.utility.initializer.Gaussian(std=0.3),
              active=rm.tanh):
     self.input_shape = input_shape
     self.output_shape = output_shape
     self.units = units
     self.depth = depth
     self.dropout = dropout
     self.active = active
     parameters = []
     add_units = units
     for _ in range(depth - 1):
         add_units += growth_rate
         parameters.append(rm.BatchNormalize())
         parameters.append(rm.Dense(add_units, initializer=initializer))
     self.hidden = rm.Sequential(parameters)
     self.input_batch = rm.BatchNormalize()
     self.input = rm.Dense(units)
     self.multi_output = False
     if isinstance(self.output_shape, tuple):
         self.multi_output = True
         parameters = []
         for _ in range(output_shape[0]):
             parameters.append(rm.BatchNormalize())
             parameters.append(
                 rm.Dense(output_shape[1], initializer=initializer))
         self.output = rm.Sequential(parameters)
     else:
         self.output = rm.Dense(output_shape)
Ejemplo n.º 5
0
def main():
    mat = scipy.io.loadmat("letter.mat")
    X = mat["X"]
    y = mat["y"]
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)

    sequential = rm.Sequential([
        rm.Dense(32),
        rm.Relu(),
        rm.Dense(16),
        rm.Relu(),
        rm.Dense(1)
    ])
    batch_size = 128
    epoch = 500
    N = len(X_train)
    optimizer = Adam()
    for i in range(epoch):
        perm = np.random.permutation(N)
        loss = 0
        for j in range(0, N//batch_size):
            train_batch = X_train[perm[j*batch_size:(j+1)*batch_size]]
            response_batch = y_train[perm[j*batch_size:(j+1)*batch_size]]
            with sequential.train():
                l = rm.sgce(sequential(train_batch), response_batch)
            grad = l.grad()
            grad.update(optimizer)
            loss += l.as_ndarray()
        train_loss = loss / (N // batch_size)
        test_loss = rm.sgce(sequential(X_test), y_test).as_ndarray()
        print("epoch:{:03d}, train_loss:{:.4f}, test_loss:{:.4f}".format(i, float(train_loss), float(test_loss)))
    predictions = np.argmax(sequential(X_test).as_ndarray(), axis=1)
    print(confusion_matrix(y_test.ravel(), predictions))
    print(classification_report(y_test.ravel(), predictions))
Ejemplo n.º 6
0
 def __init__(self, num_class):
     self.block1 = layer_factory(channel=64, conv_layer_num=1)
     self.block2 = layer_factory(channel=128, conv_layer_num=1)
     self.block3 = layer_factory(channel=256, conv_layer_num=2)
     self.block4 = layer_factory(channel=512, conv_layer_num=2)
     self.block5 = layer_factory(channel=512, conv_layer_num=2)
     self.fc1 = rm.Dense(4096)
     self.fc2 = rm.Dense(4096)
     self.fc3 = rm.Dense(num_class)
Ejemplo n.º 7
0
    def __init__(self):
        self.d1=rm.Dense(32)
        self.d2=rm.Dense(32)
        self.d3=rm.Dense(32)
        self.d4=rm.Dense(1)

        self.emb = rm.Embedding(32,6)
        self.ad1 = rm.Dense(32)
        self.r=rm.Relu()
Ejemplo n.º 8
0
 def __init__(self):
     super(Cifar10, self).__init__()
     self._l1 = rm.Conv2d(channel=32)
     self._l2 = rm.Conv2d(channel=32)
     self._l3 = rm.Conv2d(channel=64)
     self._l4 = rm.Conv2d(channel=64)
     self._l5 = rm.Dense(512)
     self._l6 = rm.Dense(10)
     self._sd = rm.SpatialDropout(dropout_ratio=0.25)
     self._pool = rm.MaxPool2d(filter=2, stride=2)
Ejemplo n.º 9
0
 def __init__(
     self,
     pre,
     latent_dim,
     output_act=None,
 ):
     self.pre = pre
     self.latent_dim = latent_dim
     self.zm_ = rm.Dense(latent_dim)
     self.zlv_ = rm.Dense(latent_dim)
     self.output_act = output_act
Ejemplo n.º 10
0
 def __init__(self, num_class=1000):
     self.block1 = layer_factory(channel=64, conv_layer_num=1)
     self.block2 = layer_factory(channel=128, conv_layer_num=1)
     self.block3 = layer_factory(channel=256, conv_layer_num=2)
     self.block4 = layer_factory(channel=512, conv_layer_num=2)
     self.block5 = layer_factory(channel=512, conv_layer_num=2)
     self.fc1 = rm.Dense(4096)
     self.dropout1 = rm.Dropout(dropout_ratio=0.5)
     self.fc2 = rm.Dense(4096)
     self.dropout2 = rm.Dropout(dropout_ratio=0.5)
     self.fc3 = rm.Dense(num_class)
Ejemplo n.º 11
0
 def __init__(self,
              input_shape=(28, 28),
              blocks=2,
              depth=3,
              growth_rate=12,
              latent_dim=10,
              dropout=False,
              intermidiate_dim=128,
              compression=0.5,
              initial_channel=8):
     self.depth = depth
     self.input_shape = input_shape
     self.latent_dim = latent_dim
     self.dropout = dropout
     self.intermidiate_dim = intermidiate_dim
     self.compression = compression
     self.growth_rate = growth_rate
     self.blocks = blocks
     print('--- Ecoding Network ---')
     parameters = []
     channels = initial_channel
     dim = self.input_shape[0]
     print('Input image {}x{}'.format(dim, dim))
     dim = dim // 2
     print(' Conv2d > {}x{} {}ch'.format(dim, dim, channels))
     self.input = rm.Conv2d(channels, filter=5, padding=2, stride=2)
     for _ in range(blocks):
         t_params, channels = self.denseblock(
             dim=dim,
             input_channels=channels,
         )
         parameters += t_params
         dim = (dim + 1) // 2
     self.hidden = rm.Sequential(parameters)
     nb_parameters = dim * dim * channels
     print(' Flatten {} params'.format(nb_parameters))
     parameters = []
     fcnn_depth = int(
         (np.log(nb_parameters / intermidiate_dim)) / np.log(4))
     nb_parameters = nb_parameters // 4
     for _ in range(fcnn_depth):
         print(' Dense {}u'.format(nb_parameters))
         parameters.append(rm.Dense(nb_parameters))
         nb_parameters = nb_parameters // 4
     print(' Dense {}u'.format(intermidiate_dim))
     parameters.append(rm.Dense(intermidiate_dim))
     print('*Mean Dense {}u'.format(latent_dim))
     parameters.append(rm.Dense(latent_dim, initializer=Uniform()))
     print('*Log Var Dense {}u'.format(latent_dim))
     parameters.append(rm.Dense(latent_dim, initializer=Gaussian(std=0.3)))
     self.fcnn = rm.Sequential(parameters)
Ejemplo n.º 12
0
 def __init__(self, classes=10):
     super(VGG19, self).__init__([
         layer_factory(channel=64, conv_layer_num=2),
         layer_factory(channel=128, conv_layer_num=2),
         layer_factory(channel=256, conv_layer_num=4),
         layer_factory(channel=512, conv_layer_num=4),
         layer_factory(channel=512, conv_layer_num=4),
         rm.Flatten(),
         rm.Dense(4096),
         rm.Dropout(0.5),
         rm.Dense(4096),
         rm.Dropout(0.5),
         rm.Dense(classes)
     ])
Ejemplo n.º 13
0
 def _gen_model(self):
     depth = self.arch['depth']
     unit = self.arch['unit']
     # excluding mini-batch size
     input_shape = self.arch['input_shape']
     output_shape = self.arch['output_shape']
     seq = []
     for i in range(depth):
         seq.append(rm.Dense(unit))
         seq.append(rm.Relu())
         if i < 1 or i == depth - 1:
             seq.append(rm.BatchNormalize())
     seq.append(rm.Dense(output_shape))
     self._model = rm.Sequential(seq)
 def __init__(self, input_shape, output_shape,
     growth_rate = 12,
     depth = 3,
     dropout = False,
     ):
     self.growth_rate = growth_rate
     self.depth = depth
     self.dropout = dropout
     self.input = rm.Dense(input_shape)
     self.output = rm.Dense(output_shape)
     parameters = []
     for _ in range(depth):
         parameters.append(rm.BatchNormalize())
         parameters.append(rm.Dense(growth_rate))
     self.hidden = rm.Sequential(parameters)
Ejemplo n.º 15
0
def test_dqn(agent, environ, fit_args, use_gpu):
    cuda.set_cuda_active(False)
    action_shape = (1,)
    state_shape = (2,)
    env = environ(action_shape, state_shape)
    network = rm.Sequential([
        rm.Dense(5),
        rm.Dense(action_shape[0]),
    ])
    model = agent(env, network)
    action = model.action(np.random.rand(*state_shape))
    assert action.shape == action_shape

    # Check fit
    model.fit(epoch=1, epoch_step=10, batch_size=4, random_step=20, test_step=10, **fit_args)
    print(model.history)
Ejemplo n.º 16
0
 def __init__(self, num_classes, block, layers, cardinality):
     self.inplanes = 128
     self.cardinality = cardinality
     super(ResNeXt, self).__init__()
     self.conv1 = rm.Conv2d(64,
                            filter=7,
                            stride=2,
                            padding=3,
                            ignore_bias=True)
     self.bn1 = rm.BatchNormalize(epsilon=0.00001, mode='feature')
     self.relu = rm.Relu()
     self.maxpool = rm.MaxPool2d(filter=3, stride=2, padding=1)
     self.layer1 = self._make_layer(block,
                                    128,
                                    layers[0],
                                    stride=1,
                                    cardinality=self.cardinality)
     self.layer2 = self._make_layer(block,
                                    256,
                                    layers[1],
                                    stride=2,
                                    cardinality=self.cardinality)
     self.layer3 = self._make_layer(block,
                                    512,
                                    layers[2],
                                    stride=2,
                                    cardinality=self.cardinality)
     self.layer4 = self._make_layer(block,
                                    1024,
                                    layers[3],
                                    stride=2,
                                    cardinality=self.cardinality)
     self.flat = rm.Flatten()
     self.fc = rm.Dense(num_classes)
Ejemplo n.º 17
0
    def _gen_model(self):
        N = self.batch

        input_shape = self.arch['input_shape']
        output_shape = self.arch['output_shape']
        if 'debug' in self.arch.keys():
            debug = self.arch['debug']
        else:
            debug = False

        self.batch_input_shape = self.get_shape(N, input_shape)
        self.batch_output_shape = self.get_shape(N, output_shape)
        depth = self.arch['depth']
        unit = self.arch['unit']

        units = np.ones(depth + 1) * unit
        _unit = np.prod(output_shape)
        units[-1] = _unit
        units = units.astype('int')
        layer = [rm.Flatten()]
        for _unit in units:
            layer.append(rm.BatchNormalize())
            layer.append(rm.Relu())
            layer.append(rm.Dense(_unit))
        #layer = layer[:-1] + [rm.Dropout()] + [layer[-1]]
        self.fcnn = rm.Sequential(layer)

        if debug:
            x = np.zeros(self.batch_input_shape)
            for _layer in layer:
                x = _layer(x)
                print(x.shape, str(_layer.__class__).split('.')[-1])
            x = rm.reshape(x, self.batch_output_shape)
            print(x.shape)
Ejemplo n.º 18
0
    def __init__(self, num_class):

        self.block1 = rm.Sequential([InceptionV4Stem(),
                                     InceptionV4BlockA(),
                                     InceptionV4BlockA(),
                                     InceptionV4BlockA(),
                                     InceptionV4BlockA(),
                                     InceptionV4ReductionA()])
        self.block2 = rm.Sequential([
            InceptionV4BlockB(),
            InceptionV4BlockB(),
            InceptionV4BlockB(),
            InceptionV4BlockB(),
            InceptionV4BlockB(),
            InceptionV4BlockB(),
            InceptionV4BlockB(),
            InceptionV4ReductionB()])
        self.block3 = rm.Sequential([
            InceptionV4BlockC(),
            InceptionV4BlockC(),
            InceptionV4BlockC(),
            rm.AveragePool2d(filter=8),
            rm.Flatten(),
            rm.Dropout(0.2)
        ])

        self.fc = rm.Dense(num_class)
 def __init__(self,):
     channel = 8
     intermidiate_dim = 128
     self.cnn1 = rm.Sequential([
         # 28x28 -> 28x28
         rm.Conv2d(channel=channel,filter=3,stride=1,padding=1),
         rm.LeakyRelu(),
         rm.Dropout(),
         # 28x28 -> 14x14
         rm.Conv2d(channel=channel*2,filter=3,stride=2,padding=1),
         rm.LeakyRelu(),
         rm.Dropout(),
         # 14x14 -> 8x8
         rm.Conv2d(channel=channel*4,filter=3,stride=2,padding=2),
         rm.LeakyRelu(),
         rm.Dropout(),
         # 8x8 -> 4x4
         rm.Conv2d(channel=channel*8,filter=3,stride=2,padding=1),
         rm.LeakyRelu(),
         rm.Dropout(),
     ])
     self.cnn2 = rm.Sequential([
         #rm.Dropout(),
         rm.Flatten(),
         #rm.Dense(intermidiate_dim)
     ])
     self.output = rm.Dense(1)
Ejemplo n.º 20
0
def test_update():
    nn = rm.Dense(2)
    nn2 = rm.Dense(2)
    with nn.train():
        ret = nn(np.random.rand(2, 2))
        loss = rm.softmax_cross_entropy(ret, np.random.rand(2, 2))

    cur = nn.params.w.copy()
    grad = loss.grad(np.array([1]))

    grad.update(models=[nn2])
    assert np.allclose(cur.as_ndarray(), nn.params.w)

    grad.update(models=[nn])
    assert np.allclose(cur.as_ndarray() - grad.get(nn.params.w),
                       nn.params.w.as_ndarray())
Ejemplo n.º 21
0
 def __init__(self, unit_size):
     self._encodelayer1 = rm.Dense(50)
     self._encodelayer2 = rm.Dense(25)
     self._encodelayer3 = rm.Dense(10)
     self._encodedlayer = rm.Dense(2)
     self._decodelayer1 = rm.Dense(10)
     self._decodelayer2 = rm.Dense(25)
     self._decodelayer3 = rm.Dense(50)
     self._decodedlayer = rm.Dense(unit_size)
Ejemplo n.º 22
0
    def __init__(self,
                 class_map=None,
                 cells=7,
                 bbox=2,
                 imsize=(224, 224),
                 load_pretrained_weight=False,
                 train_whole_network=False):

        if not hasattr(cells, "__getitem__"):
            cells = (cells, cells)

        self._cells = cells
        self._bbox = bbox
        model = Darknet()
        super(Yolov1, self).__init__(class_map, imsize, load_pretrained_weight,
                                     train_whole_network, model)

        self._last_dense_size = (self.num_class +
                                 5 * bbox) * cells[0] * cells[1]
        self._freezed_network = rm.Sequential(model[:-4])
        self._network = rm.Sequential([
            rm.Conv2d(channel=1024, filter=3, padding=1, ignore_bias=True),
            rm.BatchNormalize(mode='feature'),
            rm.LeakyRelu(slope=0.1),
            rm.Conv2d(channel=1024,
                      filter=3,
                      padding=1,
                      stride=2,
                      ignore_bias=True),
            rm.BatchNormalize(mode='feature'),
            rm.LeakyRelu(slope=0.1),
            rm.Conv2d(channel=1024, filter=3, padding=1, ignore_bias=True),
            rm.BatchNormalize(mode='feature'),
            rm.LeakyRelu(slope=0.1),
            rm.Conv2d(channel=1024, filter=3, padding=1, ignore_bias=True),
            rm.BatchNormalize(mode='feature'),
            rm.LeakyRelu(slope=0.1),
            rm.Flatten(),
            rm.Dense(
                4096
            ),  # instead of locally connected layer, we are using Dense layer
            rm.LeakyRelu(slope=0.1),
            rm.Dropout(0.5),
            rm.Dense(self._last_dense_size)
        ])
        self._opt = rm.Sgd(0.0005, 0.9)
Ejemplo n.º 23
0
 def __init__(self, x, y, batch=64, epoch=50, optimizer=Sgd):
     self.lb = LabelBinarizer().fit(y)
     self.batch = batch
     self.epoch = epoch
     self.optimizer = optimizer()
     self.network = rm.Sequential([
         rm.Dense(1)
     ])
 def __init__(self, latent_dim):
     self.latent_dim = latent_dim
     self.enc = rm.Sequential([
         #rm.BatchNormalize(),
         #rm.Dense(100),
         #rm.Dropout(),
         #rm.Relu(),
         rm.Dense(latent_dim),
         rm.Tanh()
     ])
     self.dec = rm.Sequential([
         #rm.BatchNormalize(),
         #rm.Dense(100),
         #rm.Dropout(),
         #rm.LeakyRelu(),
         rm.Dense(28 * 28),
         rm.Sigmoid()
     ])
 def __init__(
     self, input_shape, 
     output_shape, 
     growth_rate=12, 
     depth=3,
     dropout=False):
     self.depth = depth
     self.dropout = dropout
     if depth != 1:
         under_growth_rate = input_shape + growth_rate
         self.under_model = mymodel(
             under_growth_rate,
             output_shape,
             growth_rate = growth_rate,
             depth = depth - 1)
     else:
         self.output = rm.Dense(output_shape)
     self.batch = rm.BatchNormalize()
     self.conv = rm.Dense(growth_rate)
Ejemplo n.º 26
0
def exp_dense():
    np.random.seed(10)
    cuda.set_cuda_active(False)
    a = np.random.rand(32, 320).astype(np.float32)
    b = np.random.rand(32, 80).astype(np.float32)
    layer1 = rm.Dense(input_size=320, output_size=100)
    layer2 = rm.Dense(input_size=100, output_size=80)
    ga = rm.Variable(a, auto_update=False)
    gb = rm.Variable(b, auto_update=False)
    opt = Sgd(0.01, momentum=0.3)
    start_t = time.time()

    for _ in range(500):
        loss = rm.Sum((layer2(rm.Sigmoid(layer1(ga))) - gb)**2) / 32
        loss.ensure_cpu()
        print(loss)
        grad = loss.grad()
        grad.update(opt)
    print(time.time() - start_t)
Ejemplo n.º 27
0
 def __init__(self,
              feature_graph,
              num_target=1,
              fc_unit=(100, 50),
              neighbors=5,
              channels=(10, 20, 20)):
     super(GCNet, self).__init__()
     self.gc1 = GraphCNN(channel=channels[0],
                         neighbors=neighbors,
                         feature_graph=feature_graph)
     self.gc2 = GraphCNN(channel=channels[1],
                         neighbors=neighbors,
                         feature_graph=feature_graph)
     self.gc3 = GraphCNN(channel=channels[2],
                         neighbors=neighbors,
                         feature_graph=feature_graph)
     self.fc1 = rm.Dense(fc_unit[0])
     self.fc2 = rm.Dense(fc_unit[1])
     self.fc3 = rm.Dense(num_target)
     self.dropout = rm.Dropout(dropout_ratio=0.01)
Ejemplo n.º 28
0
 def __init__(
     self, pre, latent_shape,
     output_act = None,
     ):
     self.pre = pre
     self.ls = latent_shape
     _net = [rm.Dense(
         np.array(self.ls).prod() if isinstance(self.ls, tuple)
         else self.ls
     )]
     self.output_act = output_act
     self.net = rm.Sequential(_net)
Ejemplo n.º 29
0
def test_weight_decay():
    set_cuda_active(False)

    def add_weight_decay(weighted_model, decay):
        reg = rm.sum(weighted_model.params.w * weighted_model.params.w)
        return reg * (decay / 2)

    test_decay = 0.25
    input = np.random.rand(2, 2)
    unweighted_model = rm.Dense(2, input_size=(2, ))
    weighted_model = rm.Dense(2, input_size=(2, ), weight_decay=test_decay)
    unweighted_model.params['w'].setflags(write=True)
    unweighted_model.params['w'][...] = weighted_model.params['w'][...]

    set_cuda_active(True)

    with unweighted_model.train(), weighted_model.train():
        unweighted_loss = rm.sum(unweighted_model(input))
        weighted_loss = rm.sum(weighted_model(input))
        added_loss = rm.sum(unweighted_loss +
                            add_weight_decay(unweighted_model, test_decay))
    n_1 = unweighted_loss.grad(weight_decay=test_decay,
                               detach_graph=False).get(
                                   unweighted_model.params["w"])
    n_2 = weighted_loss.grad(detach_graph=False).get(
        weighted_model.params["w"])
    n_3 = added_loss.grad(detach_graph=False).get(unweighted_model.params["w"])
    map(lambda x: x.to_cpu(), [n_1, n_2, n_3])
    try:
        assert np.allclose(n_1, n_2)
        assert np.allclose(n_1, n_3)
    except AssertionError:
        print("Error in weight decay")
        print(n_1)
        print(n_2)
        print(n_3)
        assert False
Ejemplo n.º 30
0
    def __init__(self, num_class):
        self.base1 = rm.Sequential([rm.Conv2d(64, filter=7, padding=3, stride=2),
                                    rm.Relu(),
                                    rm.MaxPool2d(filter=3, stride=2, padding=1),
                                    rm.BatchNormalize(mode='feature'),
                                    rm.Conv2d(64, filter=1, stride=1),
                                    rm.Relu(),
                                    rm.Conv2d(192, filter=3, padding=1, stride=1),
                                    rm.Relu(),
                                    rm.BatchNormalize(mode='feature'),
                                    rm.MaxPool2d(filter=3, stride=2, padding=1),
                                    InceptionV1Block(),
                                    InceptionV1Block([128, 128, 192, 32, 96, 64]),
                                    rm.MaxPool2d(filter=3, stride=2),
                                    InceptionV1Block([192, 96, 208, 16, 48, 64]),
                                    ])

        self.aux1 = rm.Sequential([rm.AveragePool2d(filter=5, stride=3),
                                   rm.Flatten(),
                                   rm.Dense(1024),
                                   rm.Dense(num_class)])

        self.base2 = rm.Sequential([InceptionV1Block([160, 112, 224, 24, 64, 64]),
                                    InceptionV1Block([128, 128, 256, 24, 64, 64]),
                                    InceptionV1Block([112, 144, 288, 32, 64, 64])])

        self.aux2 = rm.Sequential([rm.AveragePool2d(filter=5, stride=3),
                                   rm.Flatten(),
                                   rm.Dense(1024),
                                   rm.Dense(num_class)])

        self.base3 = rm.Sequential([InceptionV1Block([256, 160, 320, 32, 128, 128]),
                                    InceptionV1Block([256, 160, 320, 32, 128, 128]),
                                    InceptionV1Block([192, 384, 320, 48, 128, 128]),
                                    rm.AveragePool2d(filter=7, stride=1),
                                    rm.Flatten()])
        self.aux3 = rm.Dense(num_class)