MCPcopy Index your code
hub / github.com/YesianRohn/TextSSR / save_model_hook

Function save_model_hook

train_vae.py:151–155  ·  view source on GitHub ↗
(models, weights, output_dir)

Source from the content-addressed store, hash-verified

149 if version.parse(accelerate.__version__) >= version.parse("0.16.0"):
150 # create custom saving & loading hooks so that `accelerator.save_state(...)` serializes in a nice format
151 def save_model_hook(models, weights, output_dir):
152 for i, model in enumerate(models):
153 model.save_pretrained(os.path.join(output_dir, "vae"))
154 # make sure to pop weight so that corresponding model is not saved again
155 weights.pop()
156
157 accelerator.register_save_state_pre_hook(save_model_hook)
158

Callers

nothing calls this directly

Calls 2

save_pretrainedMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected