Skip to content

Instantly share code, notes, and snippets.

View goddoe's full-sized avatar

Sungju Kim goddoe

View GitHub Profile
@goddoe
goddoe / matplotlib-NanumGothic.py
Created September 16, 2018 11:19
matplotlib NanumGothic
plt.rcParams["font.family"] = "NanumGothic"
@goddoe
goddoe / ipython_pass_param.txt
Created September 19, 2018 10:28
ipython script.py -- --argument blah
ou can use one -- more option before that:
ipython script.py -- --argument blah
Help of Ipython:
ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg] ...
If invoked with no options, it executes the file and exits, passing the
remaining arguments to the script, just as if you had specified the same
command with python. You may need to specify `--` before args to be passed
@goddoe
goddoe / data_container.py
Created September 20, 2018 07:21
DataContainer
class DataContainer(object):
def __init__(self, **kwargs):
for key, val in kwargs.items():
setattr(self, key, val)
class Net(torch.nn.Module):
def __init__(self):
self.a = torch.nn.Parameter(torch.zeros(1))
self.b = torch.zeros(1)
def forward(self, inputs):
#do some stuff
def cuda(self, device=None):
self = super().cuda(device)
@goddoe
goddoe / unsort_pytorch.py
Created September 30, 2018 17:43 — forked from keon/unsort_pytorch.py
unsort pytorch
x = torch.randn(10)
print(x)
y, ind = torch.sort(x, 0)
print("y", y)
print("ind", ind)
unsorted = y.new(*y.size())
unsorted.scatter_(0, ind, y)
print("unsorted:", unsorted)
print((x - unsorted).abs().max())
Batch Norm:
(+) Stable if the batch size is large
(+) Robust (in train) to the scale & shift of input data
(+) Robust to the scale of weight vector
(+) Scale of update decreases while training
(-) Not good for online learning
(-) Not good for RNN, LSTM
(-) Different calculation between train and test
Weight Norm:
TMPDIR=/root/users/sungju/tmp/ pip install --cache-dir=/root/users/sungju/tmp/ --build /root/users/sungju/tmp/ torch
@goddoe
goddoe / apply_multiprocessing.md
Created January 31, 2019 02:29
pandas apply multiprocessing

(ref: https://stackoverflow.com/questions/26784164/pandas-multiprocessing-apply) I'm trying to use multiprocessing with pandas dataframe, that is split the dataframe to 8 parts. apply some function to each part using apply (with each part processed in different process).

EDIT: Here's the solution I finally found:

import multiprocessing as mp
import pandas.util.testing as pdt

def process_apply(x):
@goddoe
goddoe / change docker stroage.txt
Created February 1, 2019 17:40
change docker stroage
Hello all,
I have been using Docker with the Devicemapper storage driver. After manually editing the launcher script, I finally took the time to convert to Overlay2. Here are the instructions I took to do this. I hope this helps others. I see others have asked the question 9, but I don’t see any answers. I used this excellent guide 64 to help figure this out.
Step 1: Halt your Discourse application (and other docker apps)
./launcher stop app
Step 2: Commit and save your old Docker containers/images
@goddoe
goddoe / mysql remote access.md
Created February 1, 2019 18:32
mysql remote access