model/model.py
def load_my_state_dict(self, state_dict):
        """Useful when loading part of the weights. From https://discuss.pytorch.org/t/how-to-load-part-of-pre-trained-model/1113/2"""
        own_state = self.state_dict()
        for name, param in state_dict.items():
            if name not in own_state:
                 continue
            if isinstance(param, nn.Parameter):
                # backwards compatibility for serialized parameters
                param = param.data
            own_state[name].copy_(param)
Useful when loading part of the weights. From https://discuss.pytorch.org/t/how-to-load-part-of-pre-trained-model/1113/2
Useful when loading part of the weights.
Useful when loading part of the weights .
def load_my_state_dict(self, state_dict):
        own_state = self.state_dict()
        for name, param in state_dict.items():
            if name not in own_state:
                 continue
            if isinstance(param, nn.Parameter):
                param = param.data
            own_state[name].copy_(param)
def load_my_state_dict ( self , state_dict ) : own_state = self . state_dict ( ) for name , param in state_dict . items ( ) : if name not in own_state : continue if isinstance ( param , nn . Parameter ) : param = param . data own_state [ name ] . copy_ ( param )
Useful when loading part of the weights.
Useful when loading part of the weights .
"""Useful when loading part of the weights. From https://discuss.pytorch.org/t/how-to-load-part-of-pre-trained-model/1113/2""" # backwards compatibility for serialized parameters
self
state_dict