def build_model(self) -> nn.Module: model = nn.Sequential( nn.Conv2d(NUM_CHANNELS, IMAGE_SIZE, kernel_size=(3, 3)), nn.ReLU(), nn.Conv2d(32, 32, kernel_size=(3, 3)), nn.ReLU(), nn.MaxPool2d((2, 2)), nn.Dropout2d(self.context.get_hparam("layer1_dropout")), nn.Conv2d(32, 64, (3, 3), padding=1), nn.ReLU(), nn.Conv2d(64, 64, (3, 3)), nn.ReLU(), nn.MaxPool2d((2, 2)), nn.Dropout2d(self.context.get_hparam("layer2_dropout")), Flatten(), nn.Linear(2304, 512), nn.ReLU(), nn.Dropout2d(self.context.get_hparam("layer3_dropout")), nn.Linear(512, NUM_CLASSES), nn.Softmax(dim=0), ) # If loading backbone weights, do not call reset_parameters() or # call before loading the backbone weights. reset_parameters(model) return model
def build_model(self) -> nn.Module: model = MultiNet(self.context) # If loading backbone weights, do not call reset_parameters() or # call before loading the backbone weights. reset_parameters(model) return model
def __init__(self, context): super(XORNet, self).__init__() self.main_net = nn.Sequential( nn.Linear(2, context.get_hparam("hidden_size")), nn.Sigmoid(), nn.Linear(context.get_hparam("hidden_size"), 1), nn.Sigmoid(), ) pytorch.reset_parameters(self.main_net)
def build_model(self) -> nn.Module: genotype = self.get_genotype_from_hps() model = Network( self.hparams["init_channels"], 10, # num_classes self.hparams["layers"], self.hparams["auxiliary"], genotype, ) print("param size = {} MB".format(utils.count_parameters_in_MB(model))) size = 0 for p in model.parameters(): size += p.nelement() print("param count: {}".format(size)) # If loading backbone weights, do not call reset_parameters() or # call before loading the backbone weights. reset_parameters(model) return model
def build_model(self) -> nn.Module: genotype = Genotype( normal=[ ("skip_connect", 1), ("skip_connect", 0), ("sep_conv_3x3", 2), ("sep_conv_3x3", 1), ("sep_conv_5x5", 2), ("sep_conv_3x3", 0), ("sep_conv_5x5", 3), ("sep_conv_5x5", 2), ], normal_concat=range(2, 6), reduce=[ ("max_pool_3x3", 1), ("sep_conv_3x3", 0), ("sep_conv_5x5", 1), ("dil_conv_5x5", 2), ("sep_conv_3x3", 1), ("sep_conv_3x3", 3), ("sep_conv_5x5", 1), ("max_pool_3x3", 2), ], reduce_concat=range(2, 6), ) activation_function = activation_map[self.context.get_hparam("activation")] model = NetworkImageNet( genotype, activation_function, self.context.get_hparam("init_channels"), self.context.get_hparam("num_classes"), self.context.get_hparam("layers"), auxiliary=self.context.get_hparam("auxiliary"), do_SE=self.context.get_hparam("do_SE"), ) # If loading backbone weights, do not call reset_parameters() or # call before loading the backbone weights. reset_parameters(model) return model
def build_model(self) -> nn.Module: genotype = self.get_genotype_from_hps() model = RNNModel( self.ntokens, self.hparams.emsize, self.hparams.nhid, self.hparams.nhidlast, self.hparams.dropout, self.hparams.dropouth, self.hparams.dropoutx, self.hparams.dropouti, self.hparams.dropoute, genotype=genotype, ) total_params = sum(x.data.nelement() for x in model.parameters()) logging.info("Model total parameters: {}".format(total_params)) # If loading backbone weights, do not call reset_parameters() or # call before loading the backbone weights. reset_parameters(model) return model
def build_model(self) -> nn.Module: model = nn.Sequential( nn.Conv2d(1, self.context.get_hparam("n_filters1"), 3, 1), nn.ReLU(), nn.Conv2d( self.context.get_hparam("n_filters1"), self.context.get_hparam("n_filters2"), 3, ), nn.ReLU(), nn.MaxPool2d(2), nn.Dropout2d(self.context.get_hparam("dropout1")), Flatten(), nn.Linear(144 * self.context.get_hparam("n_filters2"), 128), nn.ReLU(), nn.Dropout2d(self.context.get_hparam("dropout2")), nn.Linear(128, 10), nn.LogSoftmax(), ) # If loading backbone weights, do not call reset_parameters() or # call before loading the backbone weights. reset_parameters(model) return model