Loading fairseq/models/fairseq_model.py +6 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,12 @@ class BaseFairseqModel(nn.Module): self.upgrade_state_dict_named(state_dict, '') def upgrade_state_dict_named(self, state_dict, name): """Upgrade old state dicts to work with newer code. Args: state_dict (dict): state dictionary to upgrade, in place name (str): the state dict key corresponding to the current module """ assert state_dict is not None def do_upgrade(m, prefix): Loading fairseq/models/lstm.py +3 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,9 @@ class LSTMModel(FairseqModel): # make sure that all args are properly defaulted (in case there are any new ones) base_architecture(args) if args.encoder_layers != args.decoder_layers: raise ValueError('--encoder-layers must match --decoder-layers') def load_pretrained_embedding_from_file(embed_path, dictionary, embed_dim): num_embeddings = len(dictionary) padding_idx = dictionary.pad() Loading Loading
fairseq/models/fairseq_model.py +6 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,12 @@ class BaseFairseqModel(nn.Module): self.upgrade_state_dict_named(state_dict, '') def upgrade_state_dict_named(self, state_dict, name): """Upgrade old state dicts to work with newer code. Args: state_dict (dict): state dictionary to upgrade, in place name (str): the state dict key corresponding to the current module """ assert state_dict is not None def do_upgrade(m, prefix): Loading
fairseq/models/lstm.py +3 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,9 @@ class LSTMModel(FairseqModel): # make sure that all args are properly defaulted (in case there are any new ones) base_architecture(args) if args.encoder_layers != args.decoder_layers: raise ValueError('--encoder-layers must match --decoder-layers') def load_pretrained_embedding_from_file(embed_path, dictionary, embed_dim): num_embeddings = len(dictionary) padding_idx = dictionary.pad() Loading