def evaluate_FixedCluttered(trans_size): """ :param trans_size: :return: """ #get the fix clutter ds = tf_mnist_loader.read_data_sets("mnist_data") clutter_image = ds.train.next_batch(1)[0] clutter = np.reshape(clutter_image, (MNIST_SIZE, MNIST_SIZE)) clutter = clutter[:int(MNIST_SIZE/2), :int(MNIST_SIZE/2)] data = dataset.test batches_in_epoch = len(data._images) // batch_size accuracy = 0 for i in range(batches_in_epoch): nextX, nextY = dataset.test.next_batch(batch_size) if translateMnist: nextX, _ = convertFixedCluttered(nextX, clutter, MNIST_SIZE, trans_size, img_size) feed_dict = {inputs_placeholder: nextX, labels_placeholder: nextY, onehot_labels_placeholder: dense_to_one_hot(nextY)} r = sess.run(reward, feed_dict=feed_dict) accuracy += r accuracy /= batches_in_epoch print(("Cluttered {} ACCURACY: ".format(trans_size) + str(accuracy)))
def __init__(self, mnist_size, batch_size, translate, translated_mnist_size, monte_carlo_samples): self.mnist_size = mnist_size self.batch_size = batch_size #self.dataset = tf.contrib.learn.datasets.load_dataset("mnist") self.dataset = tf_mnist_loader.read_data_sets("MNIST-data") self.translate = translate if translate: self.translated_mnist_size = mnist_size self.mnist_size = translated_mnist_size self.M = monte_carlo_samples
def __init__(self, mnist_size, batch_size, channels, scaling, sensorBandwidth, depth, loc_std, unit_pixels, translate, translated_mnist_size): self.mnist_size = mnist_size self.batch_size = batch_size self.channels = channels # grayscale self.scaling = scaling # zooms -> scaling * 2**<depth_level> self.sensorBandwidth = sensorBandwidth # fixed resolution of sensor self.sensorArea = self.sensorBandwidth**2 self.depth = depth # zooms self.unit_pixels = unit_pixels self.dataset = tf_mnist_loader.read_data_sets("mnist_data") self.loc_std = loc_std # std when setting the location self.translate = translate if translate: self.translated_mnist_size = mnist_size self.mnist_size = translated_mnist_size
import tf_mnist_loader import matplotlib.pyplot as plt import numpy as np import time import random import sys import os add_intrinsic_reward = True try: xrange except NameError: xrange = range dataset = tf_mnist_loader.read_data_sets("mnist_data") save_dir = "chckPts/" save_prefix = "save" summaryFolderName = "summary/" # Disable GPU os.environ['CUDA_VISIBLE_DEVICES'] = '-1' if len(sys.argv) == 2: simulationName = str(sys.argv[1]) print("Simulation name = " + simulationName) summaryFolderName = summaryFolderName + simulationName + "/" saveImgs = True imgsFolderName = "imgs/" + simulationName + "/" if os.path.isdir(summaryFolderName) == False: os.mkdir(summaryFolderName)
import tensorflow as tf import tf_mnist_loader import matplotlib.pyplot as plt import numpy as np import time from tensorflow.python.ops.nn import seq2seq from tensorflow.python.ops.nn import rnn_cell import math dataset = tf_mnist_loader.read_data_sets("mnist_data") save_dir = "save-3scales/" save_prefix = "save" start_step = 0 load_path = None # load_path = save_dir + save_prefix + str(start_step) + ".ckpt" # to enable visualization, set draw to True eval_only = False animate = True draw = False minRadius = 4 # zooms -> minRadius * 2**<depth_level> sensorBandwidth = 8 # fixed resolution of sensor sensorArea = sensorBandwidth**2 depth = 3 # zooms channels = 1 # grayscale totalSensorBandwidth = depth * sensorBandwidth * sensorBandwidth * channels batch_size = 128 hg_size = 128 hl_size = 128
[ see associated documents for details. ] """ ######################### IMPORTS & VERSIONS & SETUP ######################### import tensorflow as tf import tf_mnist_loader import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt import numpy as np import time, random, sys, os, argparse from datetime import datetime startTime = datetime.now() dataset = tf_mnist_loader.read_data_sets("mnist_data", one_hot=True) inp_sz = 5; lr = 0.001 N = 10; epochs = 50 theta = 8; batchsize = 16 B = 4; disp_step = 10 phi = 16; momentum = 0.9 out_sz = 2 #inp_sz = 784; lr = 0.001 #N = 32; epochs = 50 #theta = 32; batchsize = 16 #B = 32; disp_step = 10 #phi = 32; momentum = 0.9 #out_sz = 10 #