MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / export_model

Function export_model

training/mlp_train.py:94–112  ·  view source on GitHub ↗

Write the lightweight network metadata and timeline manifest.

(
    output_path: Path,
    layer_metadata: Sequence[LayerMetadata],
    timeline: Sequence[dict[str, Any]],
)

Source from the content-addressed store, hash-verified

92
93
94def export_model(
95 output_path: Path,
96 layer_metadata: Sequence[LayerMetadata],
97 timeline: Sequence[dict[str, Any]],
98) -> None:
99 """Write the lightweight network metadata and timeline manifest."""
100 payload: dict[str, Any] = {
101 "version": 2,
102 "dtype": "float16",
103 "weights": {
104 "storage": "per_snapshot_files",
105 "format": "layer_array_v1",
106 "precision": "float16",
107 },
108 "network": build_network_payload(layer_metadata),
109 "timeline": list(timeline),
110 }
111 output_path.parent.mkdir(parents=True, exist_ok=True)
112 output_path.write_text(json.dumps(payload, indent=2))
113
114
115def evaluate(model: nn.Module, loader: DataLoader, device: torch.device) -> float:

Callers 1

mainFunction · 0.85

Calls 1

build_network_payloadFunction · 0.85

Tested by

no test coverage detected