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 threading | |
import gym | |
import os | |
from scipy.misc import imresize | |
def copy_src_to_dst(from_scope, to_scope): | |
"""Creates a copy variable weights operation |
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 gym | |
stddev = 1.0 | |
render = True | |
monitor = True | |
best_weights = tf.Variable(tf.truncated_normal(shape=[4, 1])) | |
current_weights = tf.Variable(best_weights.initialized_value()) |
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
""" | |
Solves the cartpole-v1 enviroment on OpenAI gym using policy search | |
Same algorithm as for cartpole-v0 | |
A neural network is used to store the policy | |
At the end of each episode the target value for each taken action is | |
updated with the total normalized reward (up to a learning rate) |
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
""" | |
File: cartpolev1.py | |
Created: 2017-03-09 | |
By Peter Caven, peter@sparseinference.com | |
Description: | |
-- Python 3.6 -- | |
Solve the CartPole-v1 problem: | |
- this is the same solution as for the 'CartPole-v0' problem, with the episode length extended. |
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
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |