Skip to content

Instantly share code, notes, and snippets.

View jeongukjae's full-sized avatar

Ukjae Jeong (Jay) jeongukjae

View GitHub Profile
@jeongukjae
jeongukjae / 01_list_comp.py
Last active April 19, 2023 03:35
Pythons snippet
list_var = [1, 2, 3]
# Same as list_var2 = list(map(lambda x: x+1, list_var))
list_var2 = [elem + 1 for elem in list_var]
# same as list_var3 = list(filter(lambda x: x!=1, list_var))
list_var3 = [elem for elem in list_var if elem != 1]
cmake .. \
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
-DOpenMP_CXX_LIB_NAMES="omp" \
-DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib
import tensorflow as tf
tf.random.set_seed(20)
class Layer(tf.keras.layers.Layer):
def __init__(self):
super().__init__()
self.dense = tf.keras.layers.Dense(20)
import tensorflow as tf
class TransformerEncoder(tf.keras.layers.Layer):
def __init__(self):
super().__init__()
def call(self, hidden_state):
return hidden_state
@jeongukjae
jeongukjae / amp-clipping.py
Created July 15, 2020 07:50
check gradient clipping using model.parameters() vs apex.amp.master_params(optimizer)
import torch, copy, apex
print("initialize model")
model_1 = torch.nn.Linear(1000, 2000).cuda()
model_2 = torch.nn.Linear(1000, 2000).cuda()
model_3 = torch.nn.Linear(1000, 2000).cuda()
model_1.weight = torch.nn.Parameter(model_3.weight.clone())
model_2.weight = torch.nn.Parameter(model_3.weight.clone())
@jeongukjae
jeongukjae / infer.sh
Created January 17, 2020 06:58
Tensorflow Serving Test (Preprocessing)
curl "http://localhost:8501/v1/models/test-model:predict" -XPOST -d '{"instances": ["test"]}' | jq
@jeongukjae
jeongukjae / userdata.sh
Last active April 12, 2019 01:24
aws user data to install codedeploy agent, docker and docker compose (ap-northeast-2)
#!/bin/bash
# install code deploy agent
yum -y update
yum install -y ruby
cd /home/ec2-user
curl -O https://aws-codedeploy-ap-northeast-2.s3.amazonaws.com/latest/install
chmod +x ./install
./install auto
module piezo(
rst, clk, btn, piezo, sseg
);
input rst, clk;
input [7:0] btn;
output piezo;
output [7:0] sseg;
wire piezo;
module counter(
rst, cnt, load,
cdown, cup, activeLoad,
sseg
);
input rst;
input cdown, cup, activeLoad;
input [3:0] load;
output [3:0] cnt;
module moore(rst, in, out, state);
input [1:0] in;
input rst;
output out;
output [1:0] state;
reg out;
reg [1:0] state;