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

Function tensor_to_base64

training/mlp_train.py:188–192  ·  view source on GitHub ↗
(tensor: torch.Tensor)

Source from the content-addressed store, hash-verified

186
187
188def tensor_to_base64(tensor: torch.Tensor) -> str:
189 array = tensor.detach().cpu().to(torch.float16).numpy()
190 little_endian = np.ascontiguousarray(array.astype("<f2", copy=False)).view("<u2")
191 data = little_endian.tobytes()
192 return base64.b64encode(data).decode("ascii")
193
194
195def write_snapshot_file(

Callers 1

write_snapshot_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected