Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
yang-zhang / boilerplates.md
Last active July 4, 2020 12:51
boilerplates
  • pin_memory=True
  • sigmoid used in cross_entropy_loss
  • set_seed before fold and train
@yang-zhang
yang-zhang / logging_template.py
Last active January 26, 2020 01:02
logging template
import logging
log = logging.getLogger(__name__)
log.setLevel(level=logging.DEBUG)
fmtr = logging.Formatter("[%(asctime)s] [%(levelname)-8.8s] %(message)s", "%Y-%m-%d %H:%M:%S")
fhdlr = logging.FileHandler(f"log.log", mode='w')
fhdlr.setFormatter(fmtr)
log.addHandler(fhdlr)
@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
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
Loading
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 / fastai-RNNLearner-getpreds-debug.ipynb
Last active December 24, 2018 13:54
git/yang-zhang.github.io/ds_code/fastai-RNNLearner-getpreds-debug.ipynb
Loading
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
Loading
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 / dropout-scaling.ipynb
Last active December 6, 2018 02:00
git/yang-zhang.github.io/ds_math/dropout-scaling.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.