Skip to content

Instantly share code, notes, and snippets.

Avatar

Carlos Aguayo carlos-aguayo

View GitHub Profile
@carlos-aguayo
carlos-aguayo / MCTS.py
Last active Nov 6, 2020
Part A - Select the node with the highest Upper Confidence Bound (UCB)
View MCTS.py
# 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 Nov 4, 2020
Run a Monte Carlo Tree Search (MCTS) Simulation
View MCTS.py
# 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:
View Loading MNIST.ipynb
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 Feb 23, 2019 — forked from mbostock/.block
Heatmap (2D Histogram, CSV)
View .block
license: gpl-3.0
View pg1497.txt
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
View 3 - Fine Tuning CNN.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View 2 - Using pre-trained VGG16.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View 1 - Basic Convolutional Neural Network.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:5402e0a59117b70227ecdfa3bebeb4c9
__________________________________________________________________________________________________
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 Feb 19, 2018
Given a filename, find all http links and take a screenshot of them.
View screenshot.py
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'