Exemplo n.º 1
0
    def after_training_exp(self, strategy, **kwargs):
        """
        Save a copy of the model after each experience
        and freeze the prev model and freeze the last layer of current model
        """

        self.prev_model = copy.deepcopy(strategy.model)

        freeze_everything(self.prev_model)

        last_fc_name, last_fc = get_last_fc_layer(strategy.model)

        for param in last_fc.parameters():
            param.requires_grad = False
Exemplo n.º 2
0
 def freeze_other_layers(self):
     cwr_layer = self.get_cwr_layer()
     if cwr_layer is None:
         raise RuntimeError('Can\'t find a the Linear layer')
     freeze_everything(self.model)
     unfreeze_everything(cwr_layer)