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
# https://gist.github.com/karpathy/77fbb6a8dac5395f1b73e7a89300318d | |
import gym | |
import numpy as np | |
def f(env, weight): | |
total_reward = 0.0 | |
num_run = 100 | |
for t in range(num_run): | |
observation = env.reset() | |
for i in range(300): |
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
# Simulated data and plot comes from: http://cs231n.github.io/neural-networks-case-study/ | |
import tensorflow as tf | |
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots | |
plt.rcParams['image.interpolation'] = 'nearest' | |
plt.rcParams['image.cmap'] = 'gray' |
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
# Solve CartPole-v0 | |
import tensorflow as tf | |
import numpy as np | |
import gym | |
import matplotlib.pyplot as plt | |
# hyperparameters | |
H = 10 # number of hidden layer neurons | |
learning_rate = 1e-3 |
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
# original code: https://github.com/kvfrans/openai-cartpole/blob/master/cartpole-policygradient.py | |
import tensorflow as tf | |
import numpy as np | |
import random | |
import gym | |
import math | |
import matplotlib.pyplot as plt | |
def softmax(x): |
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
# Original code from https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5 | |
# Use it to solve MountainCar-v0 | |
import numpy as np | |
import gym | |
import matplotlib.pyplot as plt | |
# hyperparameters | |
H = 10 # number of hidden layer neurons | |
batch_size = 1 # every how many episodes to do a param update? |
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
# Original code from https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5 | |
# Use it to solve CartPole-v0 | |
import numpy as np | |
import gym | |
# hyperparameters | |
H = 10 # number of hidden layer neurons | |
batch_size = 5 # every how many episodes to do a param update? | |
learning_rate = 1e-3 | |
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
# Original code from https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5 | |
# Use it to solve CartPole-v0 | |
import numpy as np | |
import gym | |
# hyperparameters | |
H = 10 # number of hidden layer neurons | |
batch_size = 5 # every how many episodes to do a param update? | |
learning_rate = 1e-2 | |
gamma = 0.99 # discount factor for reward |