MCPcopy Create free account
hub / github.com/AMAP-ML/Eevee / export_trainable_state_dict

Method export_trainable_state_dict

models/training.py:203–213  ·  view source on GitHub ↗
(self, state_dict, remove_prefix=None)

Source from the content-addressed store, hash-verified

201 return self
202
203 def export_trainable_state_dict(self, state_dict, remove_prefix=None):
204 trainable_param_names = self.trainable_param_names()
205 state_dict = {name: param for name, param in state_dict.items() if name in trainable_param_names}
206 if remove_prefix is not None:
207 state_dict_ = {}
208 for name, param in state_dict.items():
209 if name.startswith(remove_prefix):
210 name = name[len(remove_prefix):]
211 state_dict_[name] = param
212 state_dict = state_dict_
213 return state_dict
214
215 def trainable_param_names(self):
216 trainable_param_names = list(filter(lambda named_param: named_param[1].requires_grad, self.named_parameters()))

Callers 2

on_epoch_endMethod · 0.80
save_modelMethod · 0.80

Calls 1

trainable_param_namesMethod · 0.95

Tested by

no test coverage detected