MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / set_state_dict

Method set_state_dict

codegeex/paddle/codegeex_model.py:729–755  ·  view source on GitHub ↗

Customized load.

(self, state_dict, use_structured_name=True)

Source from the content-addressed store, hash-verified

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

Callers 4

set_state_dictMethod · 0.45
set_state_dictMethod · 0.45
set_state_dictMethod · 0.45
mainFunction · 0.45

Calls

no outgoing calls

Tested by 1

mainFunction · 0.36