Skip to content

Instantly share code, notes, and snippets.

@sbodenstein
sbodenstein / alphazero_pseudocode.py
Created June 7, 2020 11:06
AlphaZero Official Pseudocode
"""Pseudocode description of the AlphaZero algorithm.
Original taken from 'Data S1' from https://science.sciencemag.org/content/362/6419/1140/tab-figures-data/
"""
from __future__ import google_type_annotations
from __future__ import division
import math
import numpy
@sbodenstein
sbodenstein / benchmark_python_openspiel.py
Created May 25, 2020 15:30
Python OpenSpiel Random Game Benchmark
import numpy as np
import pyspiel
import time
def play_random_game(game):
game_state = game.new_initial_state()
while not game_state.is_terminal():
random_action = np.random.choice(game_state.legal_actions())
game_state.apply_action(random_action)
@sbodenstein
sbodenstein / benchmark_swift_openspiel.swift
Created May 25, 2020 15:28
OpenSpiel Random Game Benchmark Swift
// Build with with `-O` and `Whole Module optimization` flags
import Dispatch
import Foundation
import OpenSpiel
func playRandomGame<T: GameProtocol>(_ game: T) {
var state = game.initialState
while !state.isTerminal {
state.apply(state.legalActions.randomElement()!)
@sbodenstein
sbodenstein / sp500_market_caps.csv
Created March 31, 2020 14:07
Market Capitalizations of the S&P500 Constituents on Tuesday 31 March
marketCap
MMM 78989082624
ABT 142520418304
ABBV 112197386240
ABMD 6640275968
ACN 106709229568
ATVI 44837953536
ADBE 152021614592
AMD 55831867392
AAP 6676629504
@sbodenstein
sbodenstein / rnn_test.lua
Created July 27, 2016 23:11
Compare Torch + MXNet cuDNN RNN API's
--
require 'cudnn'
require 'cunn'
torch.setdefaulttensortype('torch.FloatTensor')
-- Get weight dim
function checkSums(rnn, seqLength, batch, inputDim, hiddenSize, layerNum, bidirectional)
rnn:reset()