Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
yang-zhang / set_seed.py
Last active January 20, 2020 14:44
set_seed function to lock pytorch randomness for reproducibility.
def set_seed(seed):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
@yang-zhang
yang-zhang / howto jupyter display dataframe options
Last active November 20, 2019 15:12
How to set dataframe display options for IPython and Jupyter notebook
import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
pd.set_option('display.max_colwidth', -1)
Keyboard Shortcut Action
Windows key Open or close Start Menu.
Windows key + A Open Action center.
Windows key + C Open Cortana in listening mode.
Windows key + D Display and hide the desktop.
Windows key + E Open File Explorer.
Windows key + G Open Game bar when a game is open.
Windows key + H Open the Share charm.
Windows key + I Open Settings.
Windows key + K Open the Connect quick action.
@yang-zhang
yang-zhang / 08_pets_tutorial-yz-20190911-dbg-image-shape.ipynb
Last active September 11, 2019 16:21
Debugging fastai_dev 08_pets_tutorial_image_dim
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yang-zhang
yang-zhang / add_env_to_jupyter_kernel.txt
Created July 8, 2019 03:00
add env to jupyter kernel
(fa1043)$ conda install ipykernel
(fa1043)$ python -m ipykernel install --user --name fa1043
@yang-zhang
yang-zhang / kjupyter
Last active July 2, 2019 17:16
kjupyter
kjupyter() {
docker run --runtime=nvidia --ipc=host -v $PWD:/tmp/working -v /data:/tmp/working/data -w=/tmp/working -p 8888:8888 --rm -it kaggle/python-gpu-build bash -c "pip install tornado==4.5.3; export LD_LIBRARY_PATH=/usr/local/cuda/lib64; pip install jupyter_contrib_nbextensions; pip install jupyter_nbextensions_configurator; jupyter contrib nbextension install --user; jupyter nbextension enable toc2/main --user; jupyter notebook --notebook-dir=/tmp/working --ip='*' --port=8888 --no-browser --allow-root"
}
@yang-zhang
yang-zhang / pytorch-losses-in-plain-python-04.ipynb
Created November 14, 2018 14:24
pytorch-losses-in-plain-python-04
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yang-zhang
yang-zhang / fastai-RNNLearner-getpreds-debug.ipynb
Last active December 24, 2018 13:54
git/yang-zhang.github.io/ds_code/fastai-RNNLearner-getpreds-debug.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yang-zhang
yang-zhang / fastai-RNNLearner-getpreds-debug.ipynb
Created December 24, 2018 03:12
fastai-RNNLearner-getpreds-debug
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yang-zhang
yang-zhang / jupyter notebook header
Last active December 8, 2018 20:54
Common commands to add to top of jupyter notebooks
%load_ext autoreload
%autoreload 2
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('max_colwidth',500)