MCPcopy Index your code
hub / github.com/zai-org/CodeGeeX / load_state_dict

Method load_state_dict

codegeex/torch/codegeex_model.py:730–756  ·  view source on GitHub ↗

Customized load.

(self, state_dict, strict=True)

Source from the content-addressed store, hash-verified

728 return state_dict_
729
730 def load_state_dict(self, state_dict, strict=True):
731 """Customized load."""
732
733 # Word embedding.
734 if self._word_embeddings_key in state_dict:
735 state_dict_ = state_dict[self._word_embeddings_key]
736 else:
737 # for backward compatibility.
738 state_dict_ = {}
739 for key in state_dict.keys():
740 if 'word_embeddings' in key:
741 state_dict_[key.split('word_embeddings.')[1]] \
742 = state_dict[key]
743 state_dict_["weight"] = state_dict_["weight"][:self.vocab_size]
744 self.word_embeddings.load_state_dict(state_dict_, strict=strict)
745
746 # Position embedding.
747 if self._position_embeddings_key in state_dict:
748 state_dict_ = state_dict[self._position_embeddings_key]
749 else:
750 # for backward compatibility.
751 state_dict_ = {}
752 for key in state_dict.keys():
753 if 'position_embeddings' in key:
754 state_dict_[key.split('position_embeddings.')[1]] \
755 = state_dict[key]
756 self.position_embeddings.load_state_dict(state_dict_, strict=strict)
757
758
759class QueryEmbedding(torch.nn.Module):

Callers 8

load_state_dictMethod · 0.45
load_state_dictMethod · 0.45
load_state_dictMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls

no outgoing calls

Tested by 2

mainFunction · 0.36
mainFunction · 0.36