def __init__(self, n_classes, dictionary): # Network architecture super(iCarlNet, self).__init__() self.n_classes = n_classes self.bs = 10 self.dictionary = dictionary #Main net self.model = resnet32() #previous model to compute the distillation loss self.prev_model = copy.deepcopy(self.model) #in feature extractor is removed the last fc layer of resnet32 self.feature_extractor = nn.Sequential(*(list(self.model.children())[:-1])) self.cuda() self.exemplars = [] self.compute_means = True # Learning method self.criterion_NLL = nn.NLLLoss() # distillation loss self.criterion_KLDiv = nn.KLDivLoss() # distillation loss self.criterion_MSE = nn.MSELoss() # calssification and distillation loss self.criterion_CE = nn.CrossEntropyLoss() # classification loss self.num_epochs = 70 self.ex_features = [] self.ex_labels = []
def __init__(self, n_classes, dictionary): # Network architecture super(iCarlNet, self).__init__() self.n_classes = n_classes self.bs = 10 self.dictionary = dictionary #Main net self.model = resnet32() #previous model to compute the distillation loss self.prev_model = copy.deepcopy(self.model) #in feature extractor is removed the last fc layer of resnet32 self.feature_extractor = nn.Sequential( *(list(self.model.children())[:-1])) #bring the model to cuda enviroment self.cuda() self.exemplars = [] # Learning method self.criterion = nn.BCEWithLogitsLoss() self.num_epochs = 70 #parameter to update for the Knn self.K_neighbors = 10
def __init__(self, n_classes, dictionary): super(LwF, self).__init__() self.model = resnet32() self.prev_model = None self.d = dictionary self.num_epochs = 70 self.optimizer = optim.SGD(self.model.parameters(), lr=2, momentum=0.9, weight_decay=1e-5) self.scheduler = optim.lr_scheduler.MultiStepLR(self.optimizer, [49, 63], gamma=0.2) self.criterion = nn.BCEWithLogitsLoss() self.n_classes = n_classes self.bs = n_classes