Skip to content

Instantly share code, notes, and snippets.

View eecrazy's full-sized avatar

Zhongyang Li eecrazy

View GitHub Profile
@eecrazy
eecrazy / make_shuffle_graphic.py
Created April 11, 2019 15:22 — forked from cshardin/make_shuffle_graphic.py
Create postscript graphic of shuffling algorithm
#!/usr/bin/env python3.6
"""
Outputs an .eps visualization of shuffling algorithm to stdout.
Requires Python 3.6+ (for f-strings).
"""
import numpy as np
def create(width, height):
print(f"""%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 {width} {height}
@eecrazy
eecrazy / tmux-cheatsheet.markdown
Created November 5, 2018 15:16 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@eecrazy
eecrazy / exp_lr_scheduler.py
Created January 5, 2018 14:19 — forked from j-min/exp_lr_scheduler.py
learning rate decay in pytorch
# http://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html
def exp_lr_scheduler(optimizer, epoch, init_lr=0.001, lr_decay_epoch=7):
"""Decay learning rate by a factor of 0.1 every lr_decay_epoch epochs."""
lr = init_lr * (0.1**(epoch // lr_decay_epoch))
if epoch % lr_decay_epoch == 0:
print('LR is set to {}'.format(lr))
for param_group in optimizer.param_groups:
@eecrazy
eecrazy / cem.py
Last active March 7, 2017 06:08
OpenAI gym Acrobot-v1
import numpy as np
import gym
from gym import wrappers
from gym.spaces import Discrete, Box
# ================================================================
# Policies
# ================================================================
class DeterministicDiscreteActionLinearPolicy(object):
import gym
import numpy as np, pandas as pd
from sklearn.neural_network import MLPClassifier
import matplotlib.pyplot as plt
env = gym.make("MountainCar-v0")
env.reset()
@eecrazy
eecrazy / cem.py
Created March 6, 2017 02:25
OpenAI gym CartPole-v0
import numpy as np
import gym
from gym import wrappers
from gym.spaces import Discrete, Box
# ================================================================
# Policies
# ================================================================
class DeterministicDiscreteActionLinearPolicy(object):
@eecrazy
eecrazy / gist:1c3e2241ee6f898822b1b7f6776b5c69
Created February 4, 2017 10:12 — forked from craigminihan/gist:b23c06afd9073ec32e0c
Build GCC 4.9.2 for C/C++ on CentOS 7
sudo yum install libmpc-devel mpfr-devel gmp-devel
cd ~/Downloads
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install
from gensim import models
sentence = models.doc2vec.LabeledSentence(
words=[u'so`bme', u'words', u'here'], tags=["SENT_0"])
sentence1 = models.doc2vec.LabeledSentence(
words=[u'here', u'we', u'go'], tags=["SENT_1"])
sentences = [sentence, sentence1]
class LabeledLineSentence(object):
@eecrazy
eecrazy / note.md
Created January 25, 2017 14:19
clang and openmp in Mac OS X

Refer to https://clang-omp.github.io/ .

We need to install something:

brew install libiomp
brew install clang-omp

Then we need to set the environment:

#kill all processes containing run_zyli
#short cut:
pss run_zyli |cut -d " " -f 7 |xargs kill
#original:
ps -ef | grep run_zyli |cut -d " " -f 7 |xargs kill