def load_encoder(self, name:str, device:torch.device=None):
        "Load the encoder `name` from the model directory."
        encoder = get_model(self.model)[0]
        if device is None: device = self.data.device
        if hasattr(encoder, 'module'): encoder = encoder.module
        encoder.load_state_dict(torch.load(self.path/self.model_dir/f'{name}.pth'))
        encoder.load_state_dict(torch.load(self.path/self.model_dir/f'{name}.pth', map_location=device))
        self.freeze()
def load_encoder ( self , name : str , device : torch . device = None ) : encoder = get_model ( self . model ) [ 0 ] if device is None : device = self . data . device if hasattr ( encoder , 'module' ) : encoder = encoder . module encoder . load_state_dict ( torch . load ( self . path / self . model_dir / f'{name}.pth' ) ) encoder . load_state_dict ( torch . load ( self . path / self . model_dir / f'{name}.pth' , map_location = device ) ) self . freeze ( )
Load the encoder `name` from the model directory.