MCPcopy
hub / github.com/cs230-stanford/cs230-code-examples / save_dict_to_json

Function save_dict_to_json

tensorflow/vision/model/utils.py:67–77  ·  view source on GitHub ↗

Saves dict of floats in json file Args: d: (dict) of float-castable values (np.float, int, float, etc.) json_path: (string) path to json file

(d, json_path)

Source from the content-addressed store, hash-verified

65
66
67def save_dict_to_json(d, json_path):
68 """Saves dict of floats in json file
69
70 Args:
71 d: (dict) of float-castable values (np.float, int, float, etc.)
72 json_path: (string) path to json file
73 """
74 with open(json_path, 'w') as f:
75 # We need to convert the values to float for json (it doesn't accept np.array, np.float, )
76 d = {k: float(v) for k, v in d.items()}
77 json.dump(d, f, indent=4)

Callers 2

evaluateFunction · 0.90
train_and_evaluateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected