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 / 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)
@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.
[[ $- != *i* ]] && return
export LANG=ja_JP.UTF-8
export PATH=$HOME/.local/bin:$PATH
export PATH=$(ruby -e 'print Gem.user_dir')/bin:$PATH
export PATH=$HOME/.node_modules/bin:$PATH
# Rust config
export PATH=$HOME/.cargo/bin:$PATH
export PATH="$HOME/.poetry/bin:$PATH"
# export PATH=$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin:$PATH
export RUST_SRC_PATH=$(rustc --print sysroot)/lib/rustlib/src/rust/src
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:
(setq debug-on-error t)
;;; Misc
(setq-default bidi-display-reordering nil)
(setq inhibit-splash-screen t)
(setq history-delete-duplicates t)
;;; 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"),