implemented data loading and normalization

This commit is contained in:
Clemens Dautermann 2019-12-11 22:27:51 +01:00
parent 01d07da8f3
commit afb48a38a1
26 changed files with 986456 additions and 3 deletions

2
.gitignore vendored
View file

@ -194,4 +194,4 @@ dmypy.json
.pyre/
# End of https://www.gitignore.io/api/python,pycharm+all
*.pt
*.pt

986410
TicTacToe_AI/Net/boards.bds Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,42 @@
import random
import torch
from tqdm import tqdm
def to_set(raw_list):
out_set = []
for line in tqdm(raw_list):
line = line.replace('\n', '')
raw_board, raw_label = line.split('|')[0], line.split('|')[1]
# convert string label to tensor
label = torch.zeros([1, 9])
if not (int(raw_label) is -1):
label[0][int(raw_label)] = 1
# convert board to tensor
raw_board = raw_board.split(',')
board = torch.zeros([1, 9])
for n, block in enumerate(raw_board):
if int(block) is -1:
board[0][n] = 0
elif int(block) is 0:
board[0][n] = 0.5
elif int(block) is 1:
board[0][n] = 1
out_set.append((board, label))
return out_set
with open('boards.bds', 'r') as infile:
print('Loading file...')
alllines = infile.readlines()
random.shuffle(alllines)
print('Generating testset...')
testset = to_set(alllines[0:50000])
print('Generating trainset...')
trainset = to_set(alllines[50001:])

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2019.9.28) 17 NOV 2019 18:39
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2019.9.28) 7 DEC 2019 21:41
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@ -1418,7 +1418,7 @@ xmf/fonts/type1/public/cm-super/sfrm0600.pfb></usr/share/texmf/fonts/type1/publ
ic/cm-super/sfrm0700.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm0800
.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm1000.pfb></usr/share/tex
mf/fonts/type1/public/cm-super/sfsl1000.pfb>
Output written on Grundlagen_des_maschinellen_lernens.pdf (8 pages, 445894 byte
Output written on Grundlagen_des_maschinellen_lernens.pdf (8 pages, 445892 byte
s).
PDF statistics:
276 PDF objects out of 1000 (max. 8388607)

View file

@ -17,6 +17,7 @@ test = datasets.MNIST('./datasets', train=False, download=True,
trainset = torch.utils.data.DataLoader(train, batch_size=10, shuffle=True)
testset = torch.utils.data.DataLoader(test, batch_size=10, shuffle=False)
class Net(nn.Module):
def __init__(self):
super().__init__()

BIN
nets/net_0.pt Normal file

Binary file not shown.

BIN
nets/net_1.pt Normal file

Binary file not shown.

BIN
nets/net_2.pt Normal file

Binary file not shown.

BIN
nets/net_3.pt Normal file

Binary file not shown.

BIN
nets/net_4.pt Normal file

Binary file not shown.

BIN
nets/net_5.pt Normal file

Binary file not shown.

BIN
nets/net_6.pt Normal file

Binary file not shown.

BIN
nets/net_7.pt Normal file

Binary file not shown.

BIN
nets/net_8.pt Normal file

Binary file not shown.