Skip to content

Instantly share code, notes, and snippets.

View seungwonpark's full-sized avatar

Seung-won Park seungwonpark

View GitHub Profile
@seungwonpark
seungwonpark / open_tf1docs.py
Last active November 17, 2022 18:48
Open tf1.15 docs via CLI
#!/usr/bin/env python3
# open tensorflow v1.15 docs via command line
# example usage: ./open_tf1docs.py tf.train.ProfilerHook
# then it will open: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/ProfilerHook
# place it in /usr/local/bin and create symlink if you want shorter alias
import sys
import webbrowser
@seungwonpark
seungwonpark / optimize.py
Created March 8, 2022 15:05
Optimizing arbitrary parameter using Adam optimizer from PyTorch
import torch
import torch.nn as nn
LEARNING_RATE = 3e-4
# we consider a toy example: minimize the squared value of single vector.
x = torch.randn(5)
m = nn.MSELoss() # for calculating loss
optimizer = torch.optim.Adam([x.requires_grad_()], lr=LEARNING_RATE)
@seungwonpark
seungwonpark / split_csd.ipynb
Last active November 29, 2021 15:33
Split CSD (Children's Song Dataset)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
% !TeX program = lualatex
\RequirePackage{luatex85}
\documentclass{standalone}
\usepackage{tikz}
\usepackage{luacode}
\usepackage{graphicx}
\definecolor{joired}{RGB}{218,11,49}
\definecolor{joigreen}{RGB}{18,136,104}
\definecolor{joiyellow}{RGB}{250,210,49}
\definecolor{joiblue}{RGB}{15,105,180}
# copy this to root directory of data and ./resample_delete.sh
# ffmpeg required
# https://unix.stackexchange.com/questions/103920/parallelize-a-bash-for-loop
open_sem(){
mkfifo pipe-$$
exec 3<>pipe-$$
rm pipe-$$
local i=$1
for((;i>0;i--)); do
@seungwonpark
seungwonpark / joi-random.py
Created August 22, 2019 11:52
JOI style random picture
# pdftoppm joi-style.pdf outputname -png -r 300 -scale-to 1024
import random
from PIL import Image
img = Image.open('joi-style-1.png')
w, h = img.size
print(img.size)
grid = 16
lw = w // grid
@seungwonpark
seungwonpark / convert.sh
Created May 26, 2019 22:52
VoxCeleb2 m4a to wav converter
# copy this to root directory of data and
# chmod a+x convert.sh
# ./convert.sh
# https://unix.stackexchange.com/questions/103920/parallelize-a-bash-for-loop
open_sem(){
mkfifo pipe-$$
exec 3<>pipe-$$
rm pipe-$$
local i=$1
@seungwonpark
seungwonpark / graph-drawing.tex
Created November 19, 2018 16:06
Automatic graph drawing with TikZ
% All you have to do is replacing `{a/1/2, b/3/4, c/2/1, d/3/2}` and `{a/b, b/c, c/d}`.
% With given example, node (a) will be drawn at coordinate (1,2), (b) in at (3,4), ...,
% and edges a-b, b-c, c-d will be drawn.
% Within `scope` environment, all nodes will be surrounded with circle.
\documentclass{standalone}
\usepackage{tikz}
\usepackage{amsmath, amssymb}
\usepackage{pgffor}
\begin{document}
\begin{tikzpicture}
@seungwonpark
seungwonpark / hasse.tex
Created October 21, 2018 20:13
Hasse diagram
\documentclass{standalone}
\usepackage{tikz}
\usepackage{amsmath,amssymb}
\usepackage{pgffor}
\usepackage{ifthen}
\begin{document}
\begin{tikzpicture}
\node(zero) at (1,0) {$ \phi $};
\foreach \i/\ii in {1/a,2.5/b,4/c,5.5/d}{
\node(\ii) at (\i, 1) {$ \left\{ \ii \right\} $};
@seungwonpark
seungwonpark / ipsc2018k1.py
Last active October 7, 2018 11:53
Draft solution of IPSC 2018 K - easy subprob.
import sys
sys.setrecursionlimit(100000)
def gcd(x, y):
return y if x%y == 0 else gcd(y, x%y)
def binary_search(s, e, a, b): # a/b
# 0: left / 1: right
m = s + e
if a == 0: