Skip to content

Instantly share code, notes, and snippets.

Kyle Kastner kastnerkyle

Block or report user

Report or block kastnerkyle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kastnerkyle
kastnerkyle / exact_pg.py
Created Jul 17, 2019 — forked from pierrelux/exact_pg.py
Exact Policy Gradient in jax, demonstrated in figure 2d of Dadashi et al. (2019)
View exact_pg.py
import jax
import jax.numpy as np
from jax import grad, jit
from jax.scipy.special import logsumexp
def dadashi_fig2d():
""" Figure 2 d) of
''The Value Function Polytope in Reinforcement Learning''
by Dadashi et al. (2019) https://arxiv.org/abs/1901.11524
View grover_large.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / vloss_single_mcts.py
Last active Jul 18, 2019
vloss MCTS for single player
View vloss_single_mcts.py
# Author: Kyle Kastner
# License: BSD 3-Clause
# based on minigo implementation
# https://github.com/tensorflow/minigo/blob/master/mcts.py
# Useful discussion of the benefits
# http://www.moderndescartes.com/essays/agz/
# single player tweaks based on
# https://tmoer.github.io/AlphaZero/
@kastnerkyle
kastnerkyle / vloss_mcts.py
Last active Jul 18, 2019
MCTS with virtual loss parallelization for leaf selection (important for minibatch move and value estimates)
View vloss_mcts.py
# Author: Kyle Kastner
# License: BSD 3-Clause
# based on minigo implementation
# https://github.com/tensorflow/minigo/blob/master/mcts.py
# Useful discussion of the benefits
# http://www.moderndescartes.com/essays/agz/
# See survey
# http://mcts.ai/pubs/mcts-survey-master.pdf
@kastnerkyle
kastnerkyle / gpt-2-wikitext-103.py
Created May 21, 2019 — forked from thomwolf/gpt-2-wikitext-103.py
A very small and self-contained gist to train a GPT-2 transformer model on wikitext-103
View gpt-2-wikitext-103.py
# Copyright (c) 2019-present, Thomas Wolf.
# All rights reserved. This source code is licensed under the MIT-style license.
""" A very small and self-contained gist to train a GPT-2 transformer model on wikitext-103 """
import os
from collections import namedtuple
from tqdm import tqdm
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from ignite.engine import Engine, Events
@kastnerkyle
kastnerkyle / top-k-top-p.py
Created May 3, 2019 — forked from thomwolf/top-k-top-p.py
Sample the next token from a probability distribution using top-k and/or nucleus (top-p) sampling
View top-k-top-p.py
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')):
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
logits: logits distribution shape (..., vocabulary size)
top_k >0: keep only top k tokens with highest probability (top-k filtering).
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering).
"""
top_k = min(top_k, logits.size(-1)) # Safety check
if top_k > 0:
# Remove all tokens with a probability less than the last token of the top-k
@kastnerkyle
kastnerkyle / Instantaneous Frequency and Phase Derivatives.ipynb
Created Mar 20, 2019
Instantaneous frequency and rainbowgrams with librosa.
View Instantaneous Frequency and Phase Derivatives.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View generate.c
// Uncompressed version of
// https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#include <stdbool.h> // 2008-2019
const int HEIGHT = 40;
const int WIDTH = 80;
@kastnerkyle
kastnerkyle / .gitignore
Created Mar 11, 2019 — forked from ctsrc/.gitignore
Random dungeon generator from https://news.ycombinator.com/item?id=19309378, deobfuscated, refactored and commented
View .gitignore
/.idea/
/cmake-build-debug/
/dungeon
View ubuntu_cuda_10.sh
sudo add-apt-repository ppa:graphics-drivers -y
sudo apt-get update
sudo apt-get install nvidia-driver-418 nvidia-utils-418 nvidia-settings -y
wget -N https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run
wget -N http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7_7.5.0.56-1+cuda10.1_amd64.deb
sudo ./cuda_10.1.105_418.39_linux.run --override --silent --toolkit --no-opengl-libs
sudo dpkg -i libcudnn7_7.5.0.56-1+cuda10.1_amd64.deb
sudo apt-get install libcupti-dev -y
You can’t perform that action at this time.