This file contains hidden or 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
def act(self, frame): | |
if np.random.rand() <= self.epsilon: | |
return self.enviroment.action_space.sample() | |
frame = np.expand_dims(np.asarray(frame).astype(np.float64), axis=0) | |
q_values = self.q_network.predict(frame) | |
return np.argmax(q_values[0]) |
This file contains hidden or 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
def _build_compile_model(self): | |
model = Sequential() | |
model.add(Conv2D(32, 8, strides=(4, 4), padding="valid",activation="relu", | |
input_shape = self._image_shape)) | |
model.add(Conv2D(64, 4, strides=(2, 2), padding="valid", activation="relu", | |
input_shape = self._image_shape)) | |
model.add(Conv2D(64, 3, strides=(1, 1), padding="valid",activation="relu", | |
input_shape = self._image_shape)) | |
model.add(Flatten()) | |
model.add(Dense(512, activation="relu")) |
This file contains hidden or 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
def __init__(self, enviroment, optimizer, image_shape): | |
# Initialize atributes | |
self._action_size = enviroment.action_space.n | |
self._optimizer = optimizer | |
self._image_shape = image_shape | |
self.enviroment = enviroment | |
self.expirience_replay = deque(maxlen=100000) | |
This file contains hidden or 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 Agent(object): | |
def __init__(self, enviroment, optimizer, image_shape): | |
# Initialize atributes | |
self._action_size = enviroment.action_space.n | |
self._optimizer = optimizer | |
self._image_shape = image_shape | |
self.enviroment = enviroment | |
self.expirience_replay = deque(maxlen=100000) |
This file contains hidden or 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
enviroment.reset() | |
frames = [] | |
for _ in range(NUMBER_OF_FRAMES): | |
enviroment.step(enviroment.action_space.sample()) | |
frames.append(enviroment.ale.getScreenRGB()) | |
img_processor.plot_frames(frames) |
This file contains hidden or 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
GAME_NAME = "BreakoutDeterministic-v4" | |
NUMBER_OF_FRAMES = 5 | |
enviroment = gym.make(GAME_NAME).env |
This file contains hidden or 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 numpy as np | |
import random | |
from collections import deque | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
import imageio | |
import os | |
import gym |
This file contains hidden or 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
// Set the training algorithm | |
var trainer = mlContext.Regression.Trainers.FastTree( | |
new FastTreeRegressionTrainer.Options() { | |
NumberOfLeaves = 98, | |
MinimumExampleCountPerLeaf = 10, | |
NumberOfTrees = 500, | |
LearningRate = 0.07655732f, | |
Shrinkage = 0.2687001f, | |
LabelColumnName = "season", | |
FeatureColumnName = "Features" |
This file contains hidden or 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
static void Main(string[] args) | |
{ | |
var regressors = new List<IEstimator<ITransformer>>() | |
{ | |
_mlContext.Regression.Trainers.Sdca(labelColumnName: "Count", featureColumnName: "Features"), | |
_mlContext.Regression.Trainers.LbfgsPoissonRegression(labelColumnName: "Count", featureColumnName: "Features"), | |
_mlContext.Regression.Trainers.FastForest(labelColumnName: "Count", featureColumnName: "Features"), | |
_mlContext.Regression.Trainers.FastTree(labelColumnName: "Count", featureColumnName: "Features"), | |
_mlContext.Regression.Trainers.FastTreeTweedie(labelColumnName: "Count", featureColumnName: "Features"), |
This file contains hidden or 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
using BikeSharingDemand.Helpers; | |
using BikeSharingDemand.ModelNamespace; | |
using Microsoft.ML; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace BikeSharingDemand | |
{ | |
class Program |