This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear ; close all; clc | |
%Get input for three terms | |
prompt = 'First three letter term? '; | |
x1 = input(prompt, 's'); | |
prompt = 'Second three letter term? '; | |
x2 = input(prompt, 's'); | |
prompt = 'Four letter answer? '; | |
y = input(prompt, 's'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
import numpy as np | |
import cPickle as pickle | |
import gym | |
# hyperparameters | |
H = 200 # number of hidden layer neurons | |
batch_size = 10 # every how many episodes to do a param update? | |
learning_rate = 1e-4 | |
gamma = 0.99 # discount factor for reward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import tensorflow.contrib.slim as slim | |
total_layers = 25 #Specify how deep we want our network | |
units_between_stride = total_layers / 5 | |
def highwayUnit(input_layer,i): | |
with tf.variable_scope("highway_unit"+str(i)): | |
H = slim.conv2d(input_layer,64,[3,3]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import tensorflow.contrib.slim as slim | |
total_layers = 25 #Specify how deep we want our network | |
units_between_stride = total_layers / 5 | |
def denseBlock(input_layer,i,j): | |
with tf.variable_scope("dense_unit"+str(i)): | |
nodes = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import tensorflow.contrib.slim as slim | |
total_layers = 25 #Specify how deep we want our network | |
units_between_stride = total_layers / 5 | |
def resUnit(input_layer,i): | |
with tf.variable_scope("res_unit"+str(i)): | |
part1 = slim.batch_norm(input_layer,activation_fn=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Worker(): | |
.... | |
.... | |
.... | |
def work(self,max_episode_length,gamma,global_AC,sess,coord): | |
episode_count = 0 | |
total_step_count = 0 | |
print "Starting worker " + str(self.number) | |
with sess.as_default(), sess.graph.as_default(): | |
while not coord.should_stop(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copies one set of variables to another. | |
# Used to set worker network parameters to those of global network. | |
def update_target_graph(from_scope,to_scope): | |
from_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, from_scope) | |
to_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, to_scope) | |
op_holder = [] | |
for from_var,to_var in zip(from_vars,to_vars): | |
op_holder.append(to_var.assign(from_var)) | |
return op_holder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with tf.device("/cpu:0"): | |
master_network = AC_Network(s_size,a_size,'global',None) # Generate global network | |
num_workers = multiprocessing.cpu_count() # Set workers ot number of available CPU threads | |
workers = [] | |
# Create worker classes | |
for i in range(num_workers): | |
workers.append(Worker(DoomGame(),i,s_size,a_size,trainer,saver,model_path)) | |
with tf.Session() as sess: | |
coord = tf.train.Coordinator() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer