Skip to content

Instantly share code, notes, and snippets.

View ysyun's full-sized avatar

Peter Yun ysyun

View GitHub Profile
@ysyun
ysyun / nvmrc-loader.plugin.zsh
Created October 6, 2021 02:05 — forked from quchao/nvmrc-loader.plugin.zsh
Calling `nvm use` automatically in a directory with a .nvmrc file
#! /usr/bin/env zsh
# Ref: https://github.com/creationix/nvm#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file
# place this after nvm initialization!
autoload -Uz add-zsh-hook
# Function: load-nvmrc
load-nvmrc() {
local _CUR_NODE_VER="$(nvm version)"
@ysyun
ysyun / basic-rnn.py
Created September 3, 2018 11:39
Basic RNN - allofdeeplearning
# Lab 12 RNN
import tensorflow as tf
import numpy as np
tf.set_random_seed(777) # reproducibility
idx2char = ['h', 'i', 'e', 'l', 'o']
# Teach hello: hihell -> ihello
x_data = [[0, 1, 0, 2, 3, 3]] # hihell
x_one_hot = [[[1, 0, 0, 0, 0], # h 0
[0, 1, 0, 0, 0], # i 1
@ysyun
ysyun / inference.sh
Created August 28, 2018 07:02
inference shell of data2vis
python -m bin.infer \
--tasks "
- class: DecodeText
params:
delimiter: '' " \
--model_dir vizmodel \
--model_params "
inference.beam_search.beam_width: 2" \
--input_pipeline "
class: ParallelTextInputPipeline
@ysyun
ysyun / nmt_large.yml
Created August 28, 2018 06:56
large train yml of data2vis
model: AttentionSeq2Seq
model_params:
attention.class: seq2seq.decoders.attention.AttentionLayerBahdanau
attention.params:
num_units: 512
bridge.class: seq2seq.models.bridges.ZeroBridge
embedding.dim: 512
encoder.class: seq2seq.encoders.BidirectionalRNNEncoder
encoder.params:
rnn_cell:
@ysyun
ysyun / loading_data_file.py
Last active August 22, 2018 05:24
Loading data in tensorflow
/*
$ cat test.csv
1,2,3,,5,6,7,8,9
0,9,8,7,6,5,4,3,2
2,3,4,5,6,7,8,9,0
5,4,3,2,16,7,8,9,3
*/
import tensorflow as tf
@ysyun
ysyun / webserver_snippet.py
Created August 21, 2018 07:52
webserver.py snippet of data2vis
def run_inference():
# tf.reset_default_graph()
with graph.as_default():
saver = tf.train.Saver()
checkpoint_path = loaded_checkpoint_path
if not checkpoint_path:
checkpoint_path = tf.train.latest_checkpoint(model_dir_input)
def session_init_op(_scaffold, sess):
saver.restore(sess, checkpoint_path)
@ysyun
ysyun / snippet of webserver.py in data2vis
Created August 21, 2018 07:51
webserver.py snippet of data2vis
def run_inference():
# tf.reset_default_graph()
with graph.as_default():
saver = tf.train.Saver()
checkpoint_path = loaded_checkpoint_path
if not checkpoint_path:
checkpoint_path = tf.train.latest_checkpoint(model_dir_input)
def session_init_op(_scaffold, sess):
saver.restore(sess, checkpoint_path)
@ysyun
ysyun / create_model_ckpt.data2vis.sh
Last active August 28, 2018 06:59
create model checkpoint of data2vis
# export DATA_DIR=project-directory
export DATA_DIR=.
python -m bin.train \
--config_paths="
$DATA_DIR/example_configs/nmt_large.yml,
$DATA_DIR/example_configs/train_seq2seq.yml,
$DATA_DIR/example_configs/text_metrics_bpe.yml" \
--model_params "
vocab_source: $DATA_DIR/sourcedata/vocab.source
vocab_target: $DATA_DIR/sourcedata/vocab.target"
@ysyun
ysyun / train_options.json
Last active August 21, 2018 06:51
train_options.json of data2vis
{
"model_class": "AttentionSeq2Seq",
"model_params": {
"encoder.params": {
"rnn_cell": {
"dropout_input_keep_prob": 0.5,
"num_layers": 2,
"cell_params": {
"num_units": 512
},
@ysyun
ysyun / React Lifecycle Methods
Created February 6, 2018 14:10 — forked from fisherwebdev/React Lifecycle Methods
Cheatsheet for React lifecycle and update cycle methods
Lifecycle: | Update:
Mounting and Unmounting | New Props or State
--------------------------------+-----------------------------------
|
getDefaultProps() | componentWillReceiveProps()*
|
getInitialState() | shouldComponentUpdate()
|
componentWillMount() | componentWillUpdate()
|