-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrain.py
More file actions
30 lines (20 loc) · 800 Bytes
/
train.py
File metadata and controls
30 lines (20 loc) · 800 Bytes
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
# train_model.py
import numpy as np
from alexnet import alexnet
WIDTH = 80
HEIGHT = 63
LR = 1e-3
EPOCHS = 8
MODEL_NAME = 'minecraft-{}-{}-{}-epochs-4-data.model'.format(LR, 'alexnetv2',EPOCHS)
model = alexnet(WIDTH, HEIGHT, LR)
train_data = np.load('training_data_balanced.npy')
train = train_data[:-10]
test = train_data[-10:]
X = np.array([i[0] for i in train]).reshape(-1,WIDTH,HEIGHT,1)
Y = [i[1] for i in train]
test_x = np.array([i[0] for i in test]).reshape(-1,WIDTH,HEIGHT,1)
test_y = [i[1] for i in test]
model.fit({'input': X}, {'targets': Y}, n_epoch=EPOCHS, validation_set=({'input': test_x}, {'targets': test_y}),
snapshot_step=10, show_metric=True, run_id=MODEL_NAME)
model.save(MODEL_NAME)
# tensorboard --logdir=foo:D:\tensor\game