-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.py
45 lines (34 loc) · 839 Bytes
/
load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"""
Create hdf5 dataset from pgn file(s)
"""
import random
import sys
import chess
import h5py
import numpy as np
from gobychess.loader import HDF5Store, Loader
chunk_size = 500
number_games = 4000
l = Loader("data/games.pgn", chunk_size)
shape_data = (3,12,64)
shape_meta = (3,)
hdf5_store_data = HDF5Store('data/data.h5', 'features', shape=shape_data)
hdf5_store_meta = HDF5Store('data/meta.h5', 'features', shape=shape_meta)
for i in range(number_games // chunk_size):
data, meta = l.generate_triplett_dataset()
hdf5_store_data.append(np.array(data))
hdf5_store_meta.append(np.array(meta))
del data
del meta
## Test
#f = h5py.File('data/data.h5', 'r')
#dset = f['features']
#
#print(dset.shape)
#
#
#f2 = h5py.File('data/meta.h5', 'r')
#dset2 = f2['features']
#
#print(dset2.shape)