forked from Sentdex/pygta5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_model.py
39 lines (23 loc) · 941 Bytes
/
train_model.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
# train_model.py
import numpy as np
from alexnet import alexnet
WIDTH = 160
HEIGHT = 120
LR = 1e-3
EPOCHS = 10
MODEL_NAME = 'pygta5-car-fast-{}-{}-{}-epochs-300K-data.model'.format(LR, 'alexnetv2',EPOCHS)
model = alexnet(WIDTH, HEIGHT, LR)
hm_data = 22
for i in range(EPOCHS):
for i in range(1,hm_data+1):
train_data = np.load('training_data-{}-balanced.npy'.format(i))
train = train_data[:-100]
test = train_data[-100:]
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=1, validation_set=({'input': test_x}, {'targets': test_y}),
snapshot_step=500, show_metric=True, run_id=MODEL_NAME)
model.save(MODEL_NAME)
# tensorboard --logdir=foo:C:/path/to/log