Skip to content

Instantly share code, notes, and snippets.

View kngwyu's full-sized avatar
🌊
I restrict email notifications, so please mention me if you nedd quick response.

Yuji Kanagawa kngwyu

🌊
I restrict email notifications, so please mention me if you nedd quick response.
View GitHub Profile
@kngwyu
kngwyu / d4rl_ret.ipynb
Last active July 13, 2021 13:15
Plot returns from D4RL datasets
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kngwyu
kngwyu / ppo_gaussian.py
Last active July 17, 2021 11:05
PPO with Gaussian Policy implemented by JAX
import dataclasses
import functools
import typing as t
import chex
import distrax
import gym
import haiku as hk
import jax
import jax.numpy as jnp
import dataclasses
from typing import Iterable, Optional, Protocol, Tuple
import numpy as np
Array = np.ndarray
@dataclasses.dataclass(frozen=True)
from typing import Dict, Tuple
import numpy as np
from matplotlib import colors as mc
from matplotlib import pyplot as plt
def _make_colormap(colors: Dict[int, str], name: str) -> mc.LinearSegmentedColormap:
z = np.sort(list(colors.keys()))
min_z = min(z)
from matplotlib import pyplot as plt
import numpy as np
from scipy.stats import beta
def plot_beta(a, b):
x = np.linspace(beta.ppf(0.01, a, b), beta.ppf(0.99, a, b), 100)
plt.plot(x, beta.pdf(x, a, b), 'r-', lw=5, alpha=0.6, label='beta pdf')
plt.title('α={} β={}'.format(a, b))
plt.show()
;;; init.el --- init file if Emacs
;;; Commentary:
;;; Code:
(package-initialize)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
require 'json'
require 'net/http'
require 'open3'
require 'optparse'
require 'pathname'
require 'rbconfig'
require 'tempfile'
require 'uri'
TEST_CASE_MAX = 120
import re
from xkeysnail.transform import *
# Emacs-like keybindings in non-Emacs applications
define_keymap(re.compile("Firefox"), {
# Ctrl+Alt+j/k to switch next/previous tab
K("Caps-M-j"): K("C-TAB"),
K("Caps-M-k"): K("C-Shift-TAB"),
# Type Caps-j to focus to the content
K("Caps-j"): K("C-f6"),
function luatex-make
set name (string split . $argv[1])[1]
if [ 2 = (count $argv) ]
set bib (string split . $argv[2])[1]
else
set bib $name
end
lualatex $name
biber $bib
lualatex $name
function venv
if mkdir $argv ^/dev/null
virtualenv --system-site-packages -p python3 $argv
. ./$argv/bin/activate.fish
else
. ./$argv/bin/activate.fish
end
end