-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.py
More file actions
23 lines (18 loc) · 739 Bytes
/
convert.py
File metadata and controls
23 lines (18 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import struct
with open("model.bin", "wb") as f:
f.write(struct.pack("II", *nb_ptc.shape)) # rows, cols
f.write(nb_ptc.tobytes(order="C"))
f.write(struct.pack("I", nb_pc.shape[0]))
f.write(nb_pc.tobytes(order="C"))
f.write(struct.pack("I", tk_nextmove_np.shape[0]))
f.write(tk_nextmove_np.tobytes(order="C"))
f.write(struct.pack("I", len(nb_classes)))
for s in nb_classes:
encoded = s.encode("utf-8")
f.write(struct.pack("I", len(encoded)))
f.write(encoded)
f.write(struct.pack("I", len(tk_output)))
for key, val in tk_output.items():
f.write(struct.pack("I", key))
f.write(struct.pack("I", len(val)))
f.write(struct.pack(f"{len(val)}i", *val))