MCPcopy
hub / github.com/huggingface/transformers / save_to_json

Method save_to_json

src/transformers/trainer_callback.py:143–147  ·  view source on GitHub ↗

Save the content of this instance in JSON format inside `json_path`.

(self, json_path: str)

Source from the content-addressed store, hash-verified

141 self.stateful_callbacks = stateful_callbacks
142
143 def save_to_json(self, json_path: str):
144 """Save the content of this instance in JSON format inside `json_path`."""
145 json_string = json.dumps(dataclasses.asdict(self), indent=2, sort_keys=True) + "\n"
146 with open(json_path, "w", encoding="utf-8") as f:
147 f.write(json_string)
148
149 @classmethod
150 def load_from_json(cls, json_path: str):

Callers 4

save_stateFunction · 0.80
_save_checkpointMethod · 0.80
_tune_save_checkpointMethod · 0.80

Calls 1

asdictMethod · 0.80

Tested by 1