Exemple #1
0
 def __init__(self, num_classes=10):
     super(LwfModel, self).__init__()
     self.num_classes = num_classes
     self.known_classes = 0
     self.old_net = None
     self.net = resnet32(num_classes=num_classes)
     self.bce_loss = nn.BCEWithLogitsLoss(reduction='mean')
def get_resnet(resnet=32):
    if resnet == 20:
        return resnet20()
    elif resnet == 32:
        return resnet32()
    elif resnet == 56:
        return resnet56()
    else:
        raise ValueError("resnet parameter must be 20 32 or 56")
    def __init__(self, num_classes=100, memory=2000):
        super(iCaRLModel, self).__init__()
        self.num_classes = num_classes
        self.memory = memory
        self.known_classes = 0
        self.old_net = None

        self.net = resnet32(num_classes=num_classes)

        self.bce_loss = nn.BCEWithLogitsLoss(reduction='mean')
        self.exemplar_sets = [{
            'indexes': [],
            'features': []
        } for label in range(num_classes)]
        self.compute_means = True
        self.means = []
    def __init__(self,
                 train_dataset: Cifar100,
                 num_classes=100,
                 memory=2000,
                 batch_size=128,
                 device='cuda'):
        super(iCaRLModel, self).__init__()
        self.num_classes = num_classes
        self.memory = memory
        self.known_classes = 0
        self.old_net = None
        self.batch_size = batch_size
        self.device = device

        self.net = resnet32(num_classes=num_classes)
        self.dataset = train_dataset

        self.bce_loss = nn.BCEWithLogitsLoss(reduction='mean')
        self.exemplar_sets = []

        self.compute_means = True
        self.exemplar_means = []