def load(cls, fn: str, conf: dict): ''' load prediction model from filename ''' device = conf.get('DEVICE') self = torch.load(fn, map_location=device) Config.__init__(self, conf) return self
def __init__(self, query_model: nn.Module, candidate_model: nn.Module, hidden_size, conf=None): nn.Module.__init__(self) Config.__init__(self, conf) # save model. self.query_model = query_model self.candidate_model = candidate_model # projection layer. self.proj = nn.Sequential( nn.Linear(3 * hidden_size, hidden_size, bias=self.USE_BIAS), activation[self.ACT_NAME](), nn.Linear(hidden_size, 2, bias=self.USE_BIAS) )
def __init__(self, config=None): nn.Module.__init__(self) Config.__init__(self, config) self._unfreeze(self.FINETUNE_LAYER_RANGE)
def __init__(self, config=None): nn.Module.__init__(self) Config.__init__(self, config) self.proto = Protonet.Prototype()