-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_default.py
48 lines (45 loc) · 1.22 KB
/
train_default.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
46
47
48
import os
import tensorflow as tf
from func import train_autoencoder, reconstruct
from utils import load_data
learning_rate = 0.001
session = tf.Session()
layer_structure = 'none'
batch_size = 100
steps = 2000
model_path = 'saved_models/default/default'
try:
os.mkdir('saved_models/')
except:
pass
try:
os.mkdir(model_path)
except:
pass
train_examples = 10000
validation_examples = 1000
(mnist,
(train_data, train_labels),
(validation_data, validation_labels)) = load_data(train_examples, validation_examples)
model = train_autoencoder(session,
train_data,
validation_data,
layer_structure,
batch_size,
steps,
learning_rate,
model_path)
model_path = 'saved_models/default/default-{}'.format(steps - 1)
figure_path = 'saved_models/default/results'
try:
os.mkdir(figure_path)
except:
pass
for i in range(10):
out_path = os.path.join(figure_path,
'mnist_{}'.format(i))
reconstruct(i,
model_path,
validation_data,
out_path,
layer_structure)