Skip to content

Instantly share code, notes, and snippets.

View yashpatel5400's full-sized avatar

Yash Patel yashpatel5400

View GitHub Profile
@yashpatel5400
yashpatel5400 / cartpole.py
Created July 25, 2017 08:15
OpenAI CartPole w/ Keras
"""
__name__ = predict.py
__author__ = Yash Patel
__description__ = Full prediction code of OpenAI Cartpole environment using Keras
"""
import gym
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Dropout
@yashpatel5400
yashpatel5400 / cartpole.py
Last active January 29, 2020 11:55
OpenAI CartPole w/ Keras: Complete
"""
__name__ = predict.py
__author__ = Yash Patel
__description__ = Full prediction code of OpenAI Cartpole environment using Keras
"""
import gym
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Dropout
@yashpatel5400
yashpatel5400 / data.py
Created July 25, 2017 08:19
OpenAI CartPole w/ Keras: Data
"""
__name__ = data.py
__author__ = Yash Patel
__description__ = Gathers the data for the Cartpole environment into the
X and Y numpy arrays for training
"""
import gym
import numpy as np
@yashpatel5400
yashpatel5400 / model.py
Last active July 25, 2017 08:20
OpenAI CartPole w/ Keras: Model
"""
__name__ = model.py
__author__ = Yash Patel
__description__ = Defines model to be trained on the Cartpole data,
predicting the directioal action to take given 4D observation state
"""
from keras.models import Sequential
from keras.layers import Dense, Dropout
@yashpatel5400
yashpatel5400 / predict.py
Created July 25, 2017 08:20
OpenAI CartPole w/ Keras: Prediction
"""
__name__ = predict.py
__author__ = Yash Patel
__description__ = Does the prediction using the defined model and data
"""
import gym
import numpy as np
from data import gather_data
import gym
import numpy as np
import random
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import Adam
from collections import deque
class DQN:
"""
solving pendulum using actor-critic model
"""
import gym
import numpy as np
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Input
from keras.layers.merge import Add, Multiply
from keras.optimizers import Adam