Keras Notebook

see https://keras.io


In [1]:
import numpy as np
from preprocessing import directory_to_data_files, sample_data, file_len

In [18]:
# Convert and save data to file (only use if you want to create a new dataset from a root directory of .sgf files or folders of .sgf files)

# root_dir = './Game_Files/9x9/GoSeigen'
# output_filename = './Data/data_9x9_GoSeigen.txt'
# directory_to_data_files(root_dir, output_filename, size=81, print_progress=True)


1/452 Processing file: ./Game_Files/9x9/computer/CC1.sgf
2/452 Processing file: ./Game_Files/9x9/computer/CC2.sgf
3/452 Processing file: ./Game_Files/9x9/computer/CC3.sgf
4/452 Processing file: ./Game_Files/9x9/computer/CC4.sgf
5/452 Processing file: ./Game_Files/9x9/computer/CC5.sgf
6/452 Processing file: ./Game_Files/9x9/computer/CC6.sgf
7/452 Processing file: ./Game_Files/9x9/computer/CM1.sgf
8/452 Processing file: ./Game_Files/9x9/computer/CM2.sgf
9/452 Processing file: ./Game_Files/9x9/computer/CM3.sgf
10/452 Processing file: ./Game_Files/9x9/computer/DO1.sgf
11/452 Processing file: ./Game_Files/9x9/computer/DO2.sgf
12/452 Processing file: ./Game_Files/9x9/computer/DO3.sgf
13/452 Processing file: ./Game_Files/9x9/computer/DO4.sgf
14/452 Processing file: ./Game_Files/9x9/computer/JI1.sgf
Exception: 'NoneType' object is not iterable. File "./Game_Files/9x9/computer/JI1.sgf" is likely malformed.
Exception: 'NoneType' object is not iterable. File "./Game_Files/9x9/computer/JI1.sgf" is likely malformed.
15/452 Processing file: ./Game_Files/9x9/computer/JI2.sgf
16/452 Processing file: ./Game_Files/9x9/computer/OZ1.sgf
Exception: property with no values. File "./Game_Files/9x9/computer/OZ2.sgf" is likely malformed.
18/452 Processing file: ./Game_Files/9x9/computer/TW.sgf
19/452 Processing file: ./Game_Files/9x9/Go_Seigen/1968-08-00.sgf
20/452 Processing file: ./Game_Files/9x9/Go_Seigen/1968-09-00a.sgf
21/452 Processing file: ./Game_Files/9x9/Minigo/000108.sgf
22/452 Processing file: ./Game_Files/9x9/Minigo/000115.sgf
23/452 Processing file: ./Game_Files/9x9/Minigo/000122.sgf
24/452 Processing file: ./Game_Files/9x9/Minigo/000129.sgf
25/452 Processing file: ./Game_Files/9x9/Minigo/000205.sgf
26/452 Processing file: ./Game_Files/9x9/Minigo/000212.sgf
27/452 Processing file: ./Game_Files/9x9/Minigo/000219.sgf
28/452 Processing file: ./Game_Files/9x9/Minigo/000611.sgf
29/452 Processing file: ./Game_Files/9x9/Minigo/000618.sgf
30/452 Processing file: ./Game_Files/9x9/Minigo/000625.sgf
31/452 Processing file: ./Game_Files/9x9/Minigo/000702.sgf
32/452 Processing file: ./Game_Files/9x9/Minigo/000709.sgf
33/452 Processing file: ./Game_Files/9x9/Minigo/000716.sgf
34/452 Processing file: ./Game_Files/9x9/Minigo/000723.sgf
35/452 Processing file: ./Game_Files/9x9/Minigo/000730.sgf
36/452 Processing file: ./Game_Files/9x9/Minigo/000806.sgf
37/452 Processing file: ./Game_Files/9x9/Minigo/000813.sgf
38/452 Processing file: ./Game_Files/9x9/Minigo/000910.sgf
39/452 Processing file: ./Game_Files/9x9/Minigo/000917.sgf
40/452 Processing file: ./Game_Files/9x9/Minigo/001001.sgf
41/452 Processing file: ./Game_Files/9x9/Minigo/001008.sgf
42/452 Processing file: ./Game_Files/9x9/Minigo/001015.sgf
43/452 Processing file: ./Game_Files/9x9/Minigo/001022.sgf
44/452 Processing file: ./Game_Files/9x9/Minigo/001029.sgf
45/452 Processing file: ./Game_Files/9x9/Minigo/001105.sgf
46/452 Processing file: ./Game_Files/9x9/Minigo/001112.sgf
47/452 Processing file: ./Game_Files/9x9/Minigo/001119.sgf
48/452 Processing file: ./Game_Files/9x9/Minigo/001126.sgf
49/452 Processing file: ./Game_Files/9x9/Minigo/001203.sgf
50/452 Processing file: ./Game_Files/9x9/Minigo/001210.sgf
51/452 Processing file: ./Game_Files/9x9/Minigo/001217.sgf
52/452 Processing file: ./Game_Files/9x9/Minigo/010107.sgf
53/452 Processing file: ./Game_Files/9x9/Minigo/010415.sgf
54/452 Processing file: ./Game_Files/9x9/Minigo/010624.sgf
55/452 Processing file: ./Game_Files/9x9/Minigo/010701.sgf
56/452 Processing file: ./Game_Files/9x9/Minigo/010708.sgf
57/452 Processing file: ./Game_Files/9x9/Minigo/010715.sgf
58/452 Processing file: ./Game_Files/9x9/Minigo/010722.sgf
59/452 Processing file: ./Game_Files/9x9/Minigo/010729.sgf
60/452 Processing file: ./Game_Files/9x9/Minigo/010805.sgf
61/452 Processing file: ./Game_Files/9x9/Minigo/010819.sgf
62/452 Processing file: ./Game_Files/9x9/Minigo/010826.sgf
63/452 Processing file: ./Game_Files/9x9/Minigo/010902.sgf
64/452 Processing file: ./Game_Files/9x9/Minigo/010909.sgf
65/452 Processing file: ./Game_Files/9x9/Minigo/010916.sgf
66/452 Processing file: ./Game_Files/9x9/Minigo/010923.sgf
67/452 Processing file: ./Game_Files/9x9/Minigo/010930.sgf
68/452 Processing file: ./Game_Files/9x9/Minigo/011007.sgf
69/452 Processing file: ./Game_Files/9x9/Minigo/011014.sgf
70/452 Processing file: ./Game_Files/9x9/Minigo/011021.sgf
71/452 Processing file: ./Game_Files/9x9/Minigo/011028.sgf
72/452 Processing file: ./Game_Files/9x9/Minigo/011104.sgf
73/452 Processing file: ./Game_Files/9x9/Minigo/011111.sgf
74/452 Processing file: ./Game_Files/9x9/Minigo/011125.sgf
75/452 Processing file: ./Game_Files/9x9/Minigo/011202.sgf
76/452 Processing file: ./Game_Files/9x9/Minigo/011209.sgf
77/452 Processing file: ./Game_Files/9x9/Minigo/011216.sgf
78/452 Processing file: ./Game_Files/9x9/Minigo/011223.sgf
79/452 Processing file: ./Game_Files/9x9/Minigo/011230.sgf
80/452 Processing file: ./Game_Files/9x9/Minigo/020106.sgf
81/452 Processing file: ./Game_Files/9x9/Minigo/020113.sgf
82/452 Processing file: ./Game_Files/9x9/Minigo/020120.sgf
83/452 Processing file: ./Game_Files/9x9/Minigo/020127.sgf
84/452 Processing file: ./Game_Files/9x9/Minigo/020203.sgf
85/452 Processing file: ./Game_Files/9x9/Minigo/020210.sgf
86/452 Processing file: ./Game_Files/9x9/Minigo/020224.sgf
87/452 Processing file: ./Game_Files/9x9/Minigo/020303.sgf
88/452 Processing file: ./Game_Files/9x9/Minigo/020310.sgf
89/452 Processing file: ./Game_Files/9x9/Minigo/020317.sgf
90/452 Processing file: ./Game_Files/9x9/Minigo/020324.sgf
91/452 Processing file: ./Game_Files/9x9/Minigo/020331.sgf
92/452 Processing file: ./Game_Files/9x9/Minigo/020407.sgf
93/452 Processing file: ./Game_Files/9x9/Minigo/020414.sgf
94/452 Processing file: ./Game_Files/9x9/Minigo/020421.sgf
95/452 Processing file: ./Game_Files/9x9/Minigo/020428.sgf
96/452 Processing file: ./Game_Files/9x9/Minigo/020505.sgf
97/452 Processing file: ./Game_Files/9x9/Minigo/020512.sgf
Exception: 'NoneType' object is not iterable. File "./Game_Files/9x9/Minigo/020512.sgf" is likely malformed.
98/452 Processing file: ./Game_Files/9x9/Minigo/020519.sgf
99/452 Processing file: ./Game_Files/9x9/Minigo/020526.sgf
100/452 Processing file: ./Game_Files/9x9/Minigo/020602.sgf
101/452 Processing file: ./Game_Files/9x9/Minigo/020609.sgf
102/452 Processing file: ./Game_Files/9x9/Minigo/020616.sgf
103/452 Processing file: ./Game_Files/9x9/Minigo/020623.sgf
104/452 Processing file: ./Game_Files/9x9/Minigo/020630.sgf
105/452 Processing file: ./Game_Files/9x9/Minigo/1.sgf
106/452 Processing file: ./Game_Files/9x9/Minigo/2.sgf
107/452 Processing file: ./Game_Files/9x9/Minigo/3.sgf
108/452 Processing file: ./Game_Files/9x9/Minigo/871010.sgf
109/452 Processing file: ./Game_Files/9x9/Minigo/871017.sgf
110/452 Processing file: ./Game_Files/9x9/Minigo/871024.sgf
111/452 Processing file: ./Game_Files/9x9/Minigo/871031.sgf
112/452 Processing file: ./Game_Files/9x9/Minigo/871107.sgf
113/452 Processing file: ./Game_Files/9x9/Minigo/871114.sgf
114/452 Processing file: ./Game_Files/9x9/Minigo/871121.sgf
115/452 Processing file: ./Game_Files/9x9/Minigo/871128.sgf
116/452 Processing file: ./Game_Files/9x9/Minigo/871205.sgf
117/452 Processing file: ./Game_Files/9x9/Minigo/871212.sgf
118/452 Processing file: ./Game_Files/9x9/Minigo/871219.sgf
119/452 Processing file: ./Game_Files/9x9/Minigo/871226.sgf
120/452 Processing file: ./Game_Files/9x9/Minigo/880109.sgf
121/452 Processing file: ./Game_Files/9x9/Minigo/880116.sgf
122/452 Processing file: ./Game_Files/9x9/Minigo/880123.sgf
123/452 Processing file: ./Game_Files/9x9/Minigo/880130.sgf
124/452 Processing file: ./Game_Files/9x9/Minigo/880206.sgf
125/452 Processing file: ./Game_Files/9x9/Minigo/880213.sgf
126/452 Processing file: ./Game_Files/9x9/Minigo/880220.sgf
127/452 Processing file: ./Game_Files/9x9/Minigo/880227.sgf
128/452 Processing file: ./Game_Files/9x9/Minigo/880305.sgf
129/452 Processing file: ./Game_Files/9x9/Minigo/880312.sgf
130/452 Processing file: ./Game_Files/9x9/Minigo/880319.sgf
131/452 Processing file: ./Game_Files/9x9/Minigo/880326.sgf
132/452 Processing file: ./Game_Files/9x9/Minigo/880402.sgf
133/452 Processing file: ./Game_Files/9x9/Minigo/880409.sgf
134/452 Processing file: ./Game_Files/9x9/Minigo/880416.sgf
135/452 Processing file: ./Game_Files/9x9/Minigo/880423.sgf
136/452 Processing file: ./Game_Files/9x9/Minigo/880430.sgf
137/452 Processing file: ./Game_Files/9x9/Minigo/880507.sgf
138/452 Processing file: ./Game_Files/9x9/Minigo/880514.sgf
139/452 Processing file: ./Game_Files/9x9/Minigo/880521.sgf
140/452 Processing file: ./Game_Files/9x9/Minigo/880528.sgf
141/452 Processing file: ./Game_Files/9x9/Minigo/880604.sgf
142/452 Processing file: ./Game_Files/9x9/Minigo/880611.sgf
143/452 Processing file: ./Game_Files/9x9/Minigo/880618.sgf
144/452 Processing file: ./Game_Files/9x9/Minigo/880625.sgf
145/452 Processing file: ./Game_Files/9x9/Minigo/880702.sgf
146/452 Processing file: ./Game_Files/9x9/Minigo/880709.sgf
147/452 Processing file: ./Game_Files/9x9/Minigo/880716.sgf
148/452 Processing file: ./Game_Files/9x9/Minigo/880723.sgf
149/452 Processing file: ./Game_Files/9x9/Minigo/880730.sgf
150/452 Processing file: ./Game_Files/9x9/Minigo/880806.sgf
151/452 Processing file: ./Game_Files/9x9/Minigo/880813.sgf
152/452 Processing file: ./Game_Files/9x9/Minigo/880820.sgf
153/452 Processing file: ./Game_Files/9x9/Minigo/880827.sgf
154/452 Processing file: ./Game_Files/9x9/Minigo/880903.sgf
155/452 Processing file: ./Game_Files/9x9/Minigo/880910.sgf
156/452 Processing file: ./Game_Files/9x9/Minigo/880917.sgf
157/452 Processing file: ./Game_Files/9x9/Minigo/881008.sgf
158/452 Processing file: ./Game_Files/9x9/Minigo/881015.sgf
159/452 Processing file: ./Game_Files/9x9/Minigo/881022.sgf
160/452 Processing file: ./Game_Files/9x9/Minigo/881029.sgf
161/452 Processing file: ./Game_Files/9x9/Minigo/881105.sgf
162/452 Processing file: ./Game_Files/9x9/Minigo/881112.sgf
163/452 Processing file: ./Game_Files/9x9/Minigo/881119.sgf
164/452 Processing file: ./Game_Files/9x9/Minigo/881126.sgf
165/452 Processing file: ./Game_Files/9x9/Minigo/881203.sgf
166/452 Processing file: ./Game_Files/9x9/Minigo/881210.sgf
167/452 Processing file: ./Game_Files/9x9/Minigo/881217.sgf
168/452 Processing file: ./Game_Files/9x9/Minigo/881224.sgf
169/452 Processing file: ./Game_Files/9x9/Minigo/881231.sgf
170/452 Processing file: ./Game_Files/9x9/Minigo/890114.sgf
171/452 Processing file: ./Game_Files/9x9/Minigo/890121.sgf
172/452 Processing file: ./Game_Files/9x9/Minigo/890128.sgf
173/452 Processing file: ./Game_Files/9x9/Minigo/890204.sgf
174/452 Processing file: ./Game_Files/9x9/Minigo/890211.sgf
175/452 Processing file: ./Game_Files/9x9/Minigo/890218.sgf
176/452 Processing file: ./Game_Files/9x9/Minigo/890225.sgf
177/452 Processing file: ./Game_Files/9x9/Minigo/890304.sgf
178/452 Processing file: ./Game_Files/9x9/Minigo/890311.sgf
179/452 Processing file: ./Game_Files/9x9/Minigo/890318.sgf
180/452 Processing file: ./Game_Files/9x9/Minigo/890325.sgf
181/452 Processing file: ./Game_Files/9x9/Minigo/890401.sgf
182/452 Processing file: ./Game_Files/9x9/Minigo/890408.sgf
183/452 Processing file: ./Game_Files/9x9/Minigo/890415.sgf
184/452 Processing file: ./Game_Files/9x9/Minigo/890422.sgf
185/452 Processing file: ./Game_Files/9x9/Minigo/890429.sgf
186/452 Processing file: ./Game_Files/9x9/Minigo/890506.sgf
187/452 Processing file: ./Game_Files/9x9/Minigo/890513.sgf
188/452 Processing file: ./Game_Files/9x9/Minigo/890520.sgf
189/452 Processing file: ./Game_Files/9x9/Minigo/890527.sgf
190/452 Processing file: ./Game_Files/9x9/Minigo/890603.sgf
191/452 Processing file: ./Game_Files/9x9/Minigo/890610.sgf
192/452 Processing file: ./Game_Files/9x9/Minigo/890617.sgf
193/452 Processing file: ./Game_Files/9x9/Minigo/890624.sgf
194/452 Processing file: ./Game_Files/9x9/Minigo/890701.sgf
195/452 Processing file: ./Game_Files/9x9/Minigo/890708.sgf
196/452 Processing file: ./Game_Files/9x9/Minigo/890715.sgf
197/452 Processing file: ./Game_Files/9x9/Minigo/890722.sgf
198/452 Processing file: ./Game_Files/9x9/Minigo/890729.sgf
199/452 Processing file: ./Game_Files/9x9/Minigo/890805.sgf
200/452 Processing file: ./Game_Files/9x9/Minigo/890812.sgf
201/452 Processing file: ./Game_Files/9x9/Minigo/890819.sgf
202/452 Processing file: ./Game_Files/9x9/Minigo/890826.sgf
203/452 Processing file: ./Game_Files/9x9/Minigo/890902.sgf
204/452 Processing file: ./Game_Files/9x9/Minigo/890909.sgf
205/452 Processing file: ./Game_Files/9x9/Minigo/890916.sgf
206/452 Processing file: ./Game_Files/9x9/Minigo/890923.sgf
207/452 Processing file: ./Game_Files/9x9/Minigo/890930.sgf
208/452 Processing file: ./Game_Files/9x9/Minigo/891007.sgf
209/452 Processing file: ./Game_Files/9x9/Minigo/891014.sgf
210/452 Processing file: ./Game_Files/9x9/Minigo/891021.sgf
211/452 Processing file: ./Game_Files/9x9/Minigo/891028.sgf
212/452 Processing file: ./Game_Files/9x9/Minigo/891104.sgf
213/452 Processing file: ./Game_Files/9x9/Minigo/891111.sgf
214/452 Processing file: ./Game_Files/9x9/Minigo/891118.sgf
215/452 Processing file: ./Game_Files/9x9/Minigo/891125.sgf
216/452 Processing file: ./Game_Files/9x9/Minigo/891202.sgf
217/452 Processing file: ./Game_Files/9x9/Minigo/891209.sgf
218/452 Processing file: ./Game_Files/9x9/Minigo/891216.sgf
219/452 Processing file: ./Game_Files/9x9/Minigo/900106.sgf
220/452 Processing file: ./Game_Files/9x9/Minigo/900113.sgf
221/452 Processing file: ./Game_Files/9x9/Minigo/900120.sgf
222/452 Processing file: ./Game_Files/9x9/Minigo/900127.sgf
223/452 Processing file: ./Game_Files/9x9/Minigo/900203.sgf
224/452 Processing file: ./Game_Files/9x9/Minigo/900210.sgf
225/452 Processing file: ./Game_Files/9x9/Minigo/900217.sgf
226/452 Processing file: ./Game_Files/9x9/Minigo/900224.sgf
227/452 Processing file: ./Game_Files/9x9/Minigo/900303.sgf
228/452 Processing file: ./Game_Files/9x9/Minigo/900310.sgf
229/452 Processing file: ./Game_Files/9x9/Minigo/900317.sgf
230/452 Processing file: ./Game_Files/9x9/Minigo/900324.sgf
231/452 Processing file: ./Game_Files/9x9/Minigo/900331.sgf
232/452 Processing file: ./Game_Files/9x9/Minigo/900414.sgf
233/452 Processing file: ./Game_Files/9x9/Minigo/900421.sgf
234/452 Processing file: ./Game_Files/9x9/Minigo/900428.sgf
235/452 Processing file: ./Game_Files/9x9/Minigo/900505.sgf
236/452 Processing file: ./Game_Files/9x9/Minigo/900512.sgf
237/452 Processing file: ./Game_Files/9x9/Minigo/900519.sgf
238/452 Processing file: ./Game_Files/9x9/Minigo/900526.sgf
239/452 Processing file: ./Game_Files/9x9/Minigo/900602.sgf
240/452 Processing file: ./Game_Files/9x9/Minigo/900609.sgf
241/452 Processing file: ./Game_Files/9x9/Minigo/900616.sgf
242/452 Processing file: ./Game_Files/9x9/Minigo/900623.sgf
243/452 Processing file: ./Game_Files/9x9/Minigo/900630.sgf
244/452 Processing file: ./Game_Files/9x9/Minigo/900707.sgf
245/452 Processing file: ./Game_Files/9x9/Minigo/900714.sgf
246/452 Processing file: ./Game_Files/9x9/Minigo/900721.sgf
247/452 Processing file: ./Game_Files/9x9/Minigo/900728.sgf
248/452 Processing file: ./Game_Files/9x9/Minigo/900804.sgf
249/452 Processing file: ./Game_Files/9x9/Minigo/900811.sgf
250/452 Processing file: ./Game_Files/9x9/Minigo/900818.sgf
251/452 Processing file: ./Game_Files/9x9/Minigo/900825.sgf
252/452 Processing file: ./Game_Files/9x9/Minigo/900901.sgf
253/452 Processing file: ./Game_Files/9x9/Minigo/900908.sgf
254/452 Processing file: ./Game_Files/9x9/Minigo/900915.sgf
255/452 Processing file: ./Game_Files/9x9/Minigo/900922.sgf
256/452 Processing file: ./Game_Files/9x9/Minigo/900929.sgf
257/452 Processing file: ./Game_Files/9x9/Minigo/901006.sgf
258/452 Processing file: ./Game_Files/9x9/Minigo/901110.sgf
259/452 Processing file: ./Game_Files/9x9/Minigo/910119.sgf
260/452 Processing file: ./Game_Files/9x9/Minigo/910209.sgf
261/452 Processing file: ./Game_Files/9x9/Minigo/910302.sgf
262/452 Processing file: ./Game_Files/9x9/Minigo/910330.sgf
263/452 Processing file: ./Game_Files/9x9/Minigo/910629.sgf
264/452 Processing file: ./Game_Files/9x9/Minigo/9109.sgf
265/452 Processing file: ./Game_Files/9x9/Minigo/920314.sgf
266/452 Processing file: ./Game_Files/9x9/Minigo/920321.sgf
267/452 Processing file: ./Game_Files/9x9/Minigo/920404.sgf
268/452 Processing file: ./Game_Files/9x9/Minigo/920502.sgf
269/452 Processing file: ./Game_Files/9x9/Minigo/920523.sgf
270/452 Processing file: ./Game_Files/9x9/Minigo/920530.sgf
271/452 Processing file: ./Game_Files/9x9/Minigo/920627.sgf
272/452 Processing file: ./Game_Files/9x9/Minigo/920815.sgf
273/452 Processing file: ./Game_Files/9x9/Minigo/920815a.sgf
274/452 Processing file: ./Game_Files/9x9/Minigo/920822.sgf
275/452 Processing file: ./Game_Files/9x9/Minigo/920829.sgf
276/452 Processing file: ./Game_Files/9x9/Minigo/920905.sgf
277/452 Processing file: ./Game_Files/9x9/Minigo/920912.sgf
278/452 Processing file: ./Game_Files/9x9/Minigo/921219.sgf
279/452 Processing file: ./Game_Files/9x9/Minigo/930116.sgf
280/452 Processing file: ./Game_Files/9x9/Minigo/930123.sgf
281/452 Processing file: ./Game_Files/9x9/Minigo/930213.sgf
282/452 Processing file: ./Game_Files/9x9/Minigo/930220.sgf
283/452 Processing file: ./Game_Files/9x9/Minigo/931030.sgf
284/452 Processing file: ./Game_Files/9x9/Minigo/931106.sgf
Exception: 'NoneType' object is not iterable. File "./Game_Files/9x9/Minigo/931106.sgf" is likely malformed.
285/452 Processing file: ./Game_Files/9x9/Minigo/931113.sgf
286/452 Processing file: ./Game_Files/9x9/Minigo/931120.sgf
287/452 Processing file: ./Game_Files/9x9/Minigo/931127.sgf
288/452 Processing file: ./Game_Files/9x9/Minigo/931204.sgf
289/452 Processing file: ./Game_Files/9x9/Minigo/931225.sgf
290/452 Processing file: ./Game_Files/9x9/Minigo/940108.sgf
291/452 Processing file: ./Game_Files/9x9/Minigo/940115.sgf
292/452 Processing file: ./Game_Files/9x9/Minigo/940122.sgf
293/452 Processing file: ./Game_Files/9x9/Minigo/940129.sgf
294/452 Processing file: ./Game_Files/9x9/Minigo/940205.sgf
295/452 Processing file: ./Game_Files/9x9/Minigo/950701.sgf
296/452 Processing file: ./Game_Files/9x9/Minigo/950708.sgf
297/452 Processing file: ./Game_Files/9x9/Minigo/950715.sgf
298/452 Processing file: ./Game_Files/9x9/Minigo/950722.sgf
299/452 Processing file: ./Game_Files/9x9/Minigo/950729.sgf
300/452 Processing file: ./Game_Files/9x9/Minigo/950805.sgf
301/452 Processing file: ./Game_Files/9x9/Minigo/950812.sgf
302/452 Processing file: ./Game_Files/9x9/Minigo/950819.sgf
Exception: 'NoneType' object is not iterable. File "./Game_Files/9x9/Minigo/950819.sgf" is likely malformed.
303/452 Processing file: ./Game_Files/9x9/Minigo/950826.sgf
304/452 Processing file: ./Game_Files/9x9/Minigo/950902.sgf
305/452 Processing file: ./Game_Files/9x9/Minigo/950909.sgf
306/452 Processing file: ./Game_Files/9x9/Minigo/950916.sgf
307/452 Processing file: ./Game_Files/9x9/Minigo/960224.sgf
308/452 Processing file: ./Game_Files/9x9/Minigo/960921.sgf
309/452 Processing file: ./Game_Files/9x9/Minigo/961102.sgf
310/452 Processing file: ./Game_Files/9x9/Minigo/970222.sgf
311/452 Processing file: ./Game_Files/9x9/Minigo/970614.sgf
312/452 Processing file: ./Game_Files/9x9/Minigo/970621.sgf
313/452 Processing file: ./Game_Files/9x9/Minigo/980328.sgf
314/452 Processing file: ./Game_Files/9x9/Minigo/980404.sgf
315/452 Processing file: ./Game_Files/9x9/Minigo/980411.sgf
316/452 Processing file: ./Game_Files/9x9/Minigo/980418.sgf
317/452 Processing file: ./Game_Files/9x9/Minigo/980425.sgf
318/452 Processing file: ./Game_Files/9x9/Minigo/980502.sgf
319/452 Processing file: ./Game_Files/9x9/Minigo/980509.sgf
320/452 Processing file: ./Game_Files/9x9/Minigo/980516.sgf
321/452 Processing file: ./Game_Files/9x9/Minigo/980523.sgf
322/452 Processing file: ./Game_Files/9x9/Minigo/980530.sgf
323/452 Processing file: ./Game_Files/9x9/Minigo/980606.sgf
324/452 Processing file: ./Game_Files/9x9/Minigo/980613.sgf
325/452 Processing file: ./Game_Files/9x9/Minigo/981003.sgf
326/452 Processing file: ./Game_Files/9x9/Minigo/981010.sgf
327/452 Processing file: ./Game_Files/9x9/Minigo/981017.sgf
328/452 Processing file: ./Game_Files/9x9/Minigo/981024.sgf
329/452 Processing file: ./Game_Files/9x9/Minigo/981031.sgf
330/452 Processing file: ./Game_Files/9x9/Minigo/981107.sgf
331/452 Processing file: ./Game_Files/9x9/Minigo/981114.sgf
332/452 Processing file: ./Game_Files/9x9/Minigo/981121.sgf
333/452 Processing file: ./Game_Files/9x9/Minigo/981128.sgf
334/452 Processing file: ./Game_Files/9x9/Minigo/981205.sgf
335/452 Processing file: ./Game_Files/9x9/Minigo/981226.sgf
336/452 Processing file: ./Game_Files/9x9/Minigo/990109.sgf
337/452 Processing file: ./Game_Files/9x9/Minigo/990116.sgf
338/452 Processing file: ./Game_Files/9x9/Minigo/990123.sgf
339/452 Processing file: ./Game_Files/9x9/Minigo/990130.sgf
340/452 Processing file: ./Game_Files/9x9/Minigo/990206.sgf
341/452 Processing file: ./Game_Files/9x9/Minigo/990213.sgf
342/452 Processing file: ./Game_Files/9x9/Minigo/990220.sgf
343/452 Processing file: ./Game_Files/9x9/Minigo/990227.sgf
344/452 Processing file: ./Game_Files/9x9/Minigo/990306.sgf
345/452 Processing file: ./Game_Files/9x9/Minigo/990313.sgf
346/452 Processing file: ./Game_Files/9x9/Minigo/990320.sgf
347/452 Processing file: ./Game_Files/9x9/Minigo/990327.sgf
348/452 Processing file: ./Game_Files/9x9/Minigo/990403.sgf
349/452 Processing file: ./Game_Files/9x9/Minigo/990410.sgf
350/452 Processing file: ./Game_Files/9x9/Minigo/990417.sgf
351/452 Processing file: ./Game_Files/9x9/Minigo/990424.sgf
352/452 Processing file: ./Game_Files/9x9/Minigo/990501.sgf
353/452 Processing file: ./Game_Files/9x9/Minigo/990508.sgf
354/452 Processing file: ./Game_Files/9x9/Minigo/990515.sgf
355/452 Processing file: ./Game_Files/9x9/Minigo/990522.sgf
356/452 Processing file: ./Game_Files/9x9/Minigo/990529.sgf
357/452 Processing file: ./Game_Files/9x9/Minigo/990605.sgf
358/452 Processing file: ./Game_Files/9x9/Minigo/990612.sgf
359/452 Processing file: ./Game_Files/9x9/Minigo/990619.sgf
360/452 Processing file: ./Game_Files/9x9/Minigo/990626.sgf
361/452 Processing file: ./Game_Files/9x9/Minigo/990703.sgf
362/452 Processing file: ./Game_Files/9x9/Minigo/990710.sgf
363/452 Processing file: ./Game_Files/9x9/Minigo/990717.sgf
364/452 Processing file: ./Game_Files/9x9/Minigo/990724.sgf
365/452 Processing file: ./Game_Files/9x9/Minigo/990731.sgf
366/452 Processing file: ./Game_Files/9x9/Minigo/990807.sgf
367/452 Processing file: ./Game_Files/9x9/Minigo/990814.sgf
368/452 Processing file: ./Game_Files/9x9/Minigo/990821.sgf
369/452 Processing file: ./Game_Files/9x9/Minigo/990828.sgf
370/452 Processing file: ./Game_Files/9x9/Minigo/990904.sgf
371/452 Processing file: ./Game_Files/9x9/Minigo/990911.sgf
372/452 Processing file: ./Game_Files/9x9/Minigo/990918.sgf
373/452 Processing file: ./Game_Files/9x9/Minigo/990925.sgf
374/452 Processing file: ./Game_Files/9x9/Minigo/991225.sgf
375/452 Processing file: ./Game_Files/9x9/Misc/500-dan-celebration.sgf
376/452 Processing file: ./Game_Files/9x9/Misc/50th-anniv-NihonKiin.sgf
377/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/1.sgf
378/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/2.sgf
379/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/3.sgf
380/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/4.sgf
381/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/5.sgf
382/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/6.sgf
383/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/7.sgf
384/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/P1.sgf
385/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/P2.sgf
386/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/P3.sgf
387/452 Processing file: ./Game_Files/9x9/Misc/IgoFestival2008/P4.sgf
388/452 Processing file: ./Game_Files/9x9/Misc/Iyama-6crown/1.sgf
389/452 Processing file: ./Game_Files/9x9/Misc/Iyama-6crown/2.sgf
390/452 Processing file: ./Game_Files/9x9/Misc/Iyama-6crown/3.sgf
391/452 Processing file: ./Game_Files/9x9/Misc/Iyama-6crown/4.sgf
392/452 Processing file: ./Game_Files/9x9/NHK/1989/1.sgf
393/452 Processing file: ./Game_Files/9x9/NHK/1989/2.sgf
394/452 Processing file: ./Game_Files/9x9/NHK/1989/3.sgf
395/452 Processing file: ./Game_Files/9x9/NHK/1989/4.sgf
396/452 Processing file: ./Game_Files/9x9/NHK/1989/5.sgf
397/452 Processing file: ./Game_Files/9x9/NHK/1991/1.sgf
398/452 Processing file: ./Game_Files/9x9/NHK/1991/2.sgf
399/452 Processing file: ./Game_Files/9x9/NHK/1991/3.sgf
400/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/1.sgf
401/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/2.sgf
402/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/3.sgf
403/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/4.sgf
404/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/5.sgf
405/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/6.sgf
406/452 Processing file: ./Game_Files/9x9/NHK/NewYear1990/7.sgf
407/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/1.sgf
Exception: list index out of range. File "./Game_Files/9x9/NHK/NewYear2002/1.sgf" is likely malformed.
408/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/2.sgf
Exception: list index out of range. File "./Game_Files/9x9/NHK/NewYear2002/2.sgf" is likely malformed.
409/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/3.sgf
Exception: list index out of range. File "./Game_Files/9x9/NHK/NewYear2002/3.sgf" is likely malformed.
410/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/4.sgf
Exception: list index out of range. File "./Game_Files/9x9/NHK/NewYear2002/4.sgf" is likely malformed.
411/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/5.sgf
412/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/6.sgf
Exception: list index out of range. File "./Game_Files/9x9/NHK/NewYear2002/6.sgf" is likely malformed.
413/452 Processing file: ./Game_Files/9x9/NHK/NewYear2002/7.sgf
Exception: list index out of range. File "./Game_Files/9x9/NHK/NewYear2002/7.sgf" is likely malformed.
414/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/1.sgf
415/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/2.sgf
416/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/3.sgf
417/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/4.sgf
418/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/5.sgf
419/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/6.sgf
420/452 Processing file: ./Game_Files/9x9/NHK/NewYear2003/7.sgf
421/452 Processing file: ./Game_Files/9x9/NHK/NewYear2009/1.sgf
422/452 Processing file: ./Game_Files/9x9/NHK/NewYear2009/2.sgf
423/452 Processing file: ./Game_Files/9x9/NHK/NewYear2009/3.sgf
424/452 Processing file: ./Game_Files/9x9/NHK/NewYear2009/4.sgf
425/452 Processing file: ./Game_Files/9x9/RicohPG/pg2003-d-1.sgf
426/452 Processing file: ./Game_Files/9x9/RicohPG/pg2003-d-2.sgf
427/452 Processing file: ./Game_Files/9x9/RicohPG/pg2003-d-3.sgf
428/452 Processing file: ./Game_Files/9x9/RicohPG/pg2003-d-4.sgf
429/452 Processing file: ./Game_Files/9x9/RicohPG/pg2004-d-1.sgf
430/452 Processing file: ./Game_Files/9x9/RicohPG/pg2004-d-2.sgf
431/452 Processing file: ./Game_Files/9x9/RicohPG/pg2004-d-3.sgf
432/452 Processing file: ./Game_Files/9x9/RicohPG/pg2004-d-4.sgf
433/452 Processing file: ./Game_Files/9x9/RicohPG/pg2005-d-1.sgf
434/452 Processing file: ./Game_Files/9x9/RicohPG/pg2005-d-2.sgf
435/452 Processing file: ./Game_Files/9x9/RicohPG/pg2005-d-3.sgf
436/452 Processing file: ./Game_Files/9x9/RicohPG/pg2005-d-4.sgf
437/452 Processing file: ./Game_Files/9x9/RicohPG/pg2006-d-1.sgf
438/452 Processing file: ./Game_Files/9x9/RicohPG/pg2006-d-2.sgf
439/452 Processing file: ./Game_Files/9x9/RicohPG/pg2006-d-3.sgf
440/452 Processing file: ./Game_Files/9x9/RicohPG/pg2006-d-4.sgf
441/452 Processing file: ./Game_Files/9x9/RicohPG/pg2007-d-1.sgf
442/452 Processing file: ./Game_Files/9x9/RicohPG/pg2007-d-2.sgf
443/452 Processing file: ./Game_Files/9x9/RicohPG/pg2007-d-3.sgf
444/452 Processing file: ./Game_Files/9x9/RicohPG/pg2007-d-4.sgf
445/452 Processing file: ./Game_Files/9x9/RicohPG/pg2008-d-1.sgf
446/452 Processing file: ./Game_Files/9x9/RicohPG/pg2008-d-2.sgf
447/452 Processing file: ./Game_Files/9x9/RicohPG/pg2008-d-3.sgf
448/452 Processing file: ./Game_Files/9x9/RicohPG/pg2008-d-4.sgf
449/452 Processing file: ./Game_Files/9x9/RicohPG/pg2009-d-1.sgf
450/452 Processing file: ./Game_Files/9x9/RicohPG/pg2009-d-2.sgf
451/452 Processing file: ./Game_Files/9x9/RicohPG/pg2009-d-3.sgf
452/452 Processing file: ./Game_Files/9x9/RicohPG/pg2009-d-4.sgf

In [2]:
# Load data from file
data_filename = './Data/data_9x9.txt'
max_examples = file_len(data_filename)
k = max_examples  # Number of training examples to randomly sample from data file (note: repeated sampling could give repeat examples)
k = min(k, max_examples)  # Don't try to sample more examples than rows in the data file

winners, vectors, next_move_vectors = sample_data(data_filename, k=k)
X = np.array(vectors)  # Convert list of vectors into 2D array X
Y = np.array(next_move_vectors)  # Convert list of next_move_vectors into 2D array Y
winners = np.array(winners)  # Convert list of winners into 1D array winners
print X.shape, Y.shape, winners.shape


(20742, 81) (20742, 81) (20742,)

In [14]:
from keras.models import Sequential
from keras.layers import Dense, Activation

model = Sequential()

# Define sequential model steps
model.add(Dense(output_dim=81, input_dim=81))
model.add(Activation("relu"))
model.add(Dense(output_dim=81))
model.add(Activation("softmax"))
 
# Compile model
model.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy'])

In [15]:
# Train/Test split
from sklearn.model_selection import train_test_split
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=42)

In [16]:
# Train model
model.fit(X_train, Y_train, nb_epoch=10, batch_size=32)
#model.train_on_batch(X_batch, Y_batch)


Epoch 1/10
16593/16593 [==============================] - 1s - loss: 4.4357 - acc: 0.0168     
Epoch 2/10
16593/16593 [==============================] - 1s - loss: 4.3937 - acc: 0.0191     
Epoch 3/10
16593/16593 [==============================] - 1s - loss: 4.3639 - acc: 0.0228     
Epoch 4/10
16593/16593 [==============================] - 1s - loss: 4.3403 - acc: 0.0265     
Epoch 5/10
16593/16593 [==============================] - 1s - loss: 4.3203 - acc: 0.0286     
Epoch 6/10
16593/16593 [==============================] - 1s - loss: 4.3025 - acc: 0.0363     
Epoch 7/10
16593/16593 [==============================] - 1s - loss: 4.2862 - acc: 0.0410     
Epoch 8/10
16593/16593 [==============================] - 2s - loss: 4.2708 - acc: 0.0440     
Epoch 9/10
16593/16593 [==============================] - 1s - loss: 4.2560 - acc: 0.0465     
Epoch 10/10
16593/16593 [==============================] - 1s - loss: 4.2418 - acc: 0.0466     
Out[16]:
<keras.callbacks.History at 0x10cdb49d0>

In [17]:
# Evaluate model performance
loss_and_metrics = model.evaluate(X_test, Y_test, batch_size=32)
loss_and_metrics


2624/4149 [=================>............] - ETA: 0s
Out[17]:
[4.2845058656077866, 0.040491684752290411]

In [18]:
# Generate new predictions
classes = model.predict_classes(X_test, batch_size=32)
proba = model.predict_proba(X_test, batch_size=32)


2464/4149 [================>.............] - ETA: 0s

In [ ]: