Skip to content

Instantly share code, notes, and snippets.

View carlos-aguayo's full-sized avatar

Carlos Aguayo carlos-aguayo

View GitHub Profile
@carlos-aguayo
carlos-aguayo / CartPole-v0.py
Last active April 7, 2021 03:30
OpenAI Gym CartPole-v0
import gym
import pandas as pd
import numpy as np
import random
# https://gym.openai.com/envs/CartPole-v0
# Carlos Aguayo - carlos.aguayo@gmail.com
class QLearner(object):
@carlos-aguayo
carlos-aguayo / MCTS.py
Last active November 6, 2020 01:47
Part A - Select the node with the highest Upper Confidence Bound (UCB)
# https://github.com/suragnair/alpha-zero-general/blob/5156c7fd1d2f3e5fefe732a4b2e0ffc5b272f819/MCTS.py#L105-L121
cur_best = -float('inf')
best_act = -1
# pick the action with the highest upper confidence bound
for a in range(self.game.getActionSize()):
if valids[a]:
if (s, a) in self.Qsa:
u = self.Qsa[(s, a)] + self.args.cpuct * self.Ps[s][a] * math.sqrt(self.Ns[s]) / (
1 + self.Nsa[(s, a)])
@carlos-aguayo
carlos-aguayo / MCTS.py
Last active November 4, 2020 23:58
Run a Monte Carlo Tree Search (MCTS) Simulation
# https://github.com/suragnair/alpha-zero-general/blob/5156c7fd1d2f3e5fefe732a4b2e0ffc5b272f819/MCTS.py#L37-L48
for i in range(self.args.numMCTSSims): # self.args.numMCTSSims, the number of MCTS simulations to compute
self.search(canonicalBoard) # "search" is a MCTS simulations
s = self.game.stringRepresentation(canonicalBoard)
# Count how many times we have visited each node
counts = [self.Nsa[(s, a)] if (s, a) in self.Nsa else 0 for a in range(self.game.getActionSize())]
if temp == 0:
@carlos-aguayo
carlos-aguayo / gist:5402e0a59117b70227ecdfa3bebeb4c9
Created February 22, 2018 04:16
Inception-V3 Model Summary
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) (None, None, None, 3 0
__________________________________________________________________________________________________
conv2d_1 (Conv2D) (None, None, None, 3 864 input_1[0][0]
__________________________________________________________________________________________________
batch_normalization_1 (BatchNor (None, None, None, 3 96 conv2d_1[0][0]
__________________________________________________________________________________________________
activation_1 (Activation) (None, None, None, 3 0 batch_normalization_1[0][0]
@carlos-aguayo
carlos-aguayo / Loading MNIST.ipynb
Last active February 13, 2020 21:36
Loading MNIST
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carlos-aguayo
carlos-aguayo / .block
Created February 23, 2019 17:25 — forked from mbostock/.block
Heatmap (2D Histogram, CSV)
license: gpl-3.0
This file has been truncated, but you can view the full file.
The Project Gutenberg EBook of The Republic, by Plato
This eBook is for the use of anyone anywhere at no cost and with
almost no restrictions whatsoever. You may copy it, give it away or
re-use it under the terms of the Project Gutenberg License included
with this eBook or online at www.gutenberg.org
Title: The Republic
@carlos-aguayo
carlos-aguayo / voicegender.py
Created July 19, 2017 22:07
Comparison for XGBoost, LightGBM and a Neural Network
import pandas as pd
from xgboost import XGBClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import LabelEncoder
dataset = pd.read_csv('https://github.com/primaryobjects/voice-gender/raw/master/voice.csv', header=0).values
x = dataset[:, :-1]
y = dataset[:, -1]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.