-
Notifications
You must be signed in to change notification settings - Fork 0
/
ram.py
51 lines (40 loc) · 1.19 KB
/
ram.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
49
50
#import matplotlib
#matplotlib.use('Agg')
from data.mnist import mnistData
from data.multithread import mtWrapper
import numpy as np
import pdb
batch_size = 32
device = "/gpu:1"
mt = False
#Get object from which tensorflow will pull data from
#TODO cross validation
path = "/home/slundquist/mountData/datasets/mnist"
if(mt):
#Make new class based on mnist class
mt_mnistData = mtWrapper(mnistData, batch_size)
#Instantiate class
dataObj = mt_mnistData(path)
else:
dataObj = mnistData(path)
#Load default params
from params.ram import RamParams
params = RamParams()
#Overwrite various params
params.device = device
params.original_size = dataObj.inputShape
params.num_train_examples = dataObj.num_train_examples
#dataObj = mtWrapper(dataObj, params.batch_size)
from tf.RAM import RAM
#Loop through num_glimpses
for nglimpse in range(2, 8):
params.run_dir = params.out_dir + "/ram_base_nglimpse_" + str(nglimpse) + "/"
params.num_glimpses = nglimpse
#Allocate tensorflow object
#This will build the graph
tfObj = RAM(params)
print("Done init")
tfObj.trainModel(dataObj)
tfObj.evalModelBatch(dataObj, writeOut=True)
print("Done run")
tfObj.closeSess()