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 / 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 / Loading MNIST.ipynb
Last active February 13, 2020 21:36
Loading MNIST
Loading
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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 / 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 / screenshot.py
Created February 19, 2018 21:19
Given a filename, find all http links and take a screenshot of them.
from selenium import webdriver
from BeautifulSoup import BeautifulSoup
import requests
options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=options)
driver.set_window_size(1280, 1600)
filename = 'NOTICE.html'