Skip to content

Instantly share code, notes, and snippets.

View boilerplates.md
  • pin_memory=True
  • sigmoid used in cross_entropy_loss
  • set_seed before fold and train
View logging_template.py
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 Jan 20, 2020
set_seed function to lock pytorch randomness for reproducibility.
View set_seed.py
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
View window10_shortcuts
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 Sep 11, 2019
Debugging fastai_dev 08_pets_tutorial_image_dim
View 08_pets_tutorial-yz-20190911-dbg-image-shape.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View add_env_to_jupyter_kernel.txt
(fa1043)$ conda install ipykernel
(fa1043)$ python -m ipykernel install --user --name fa1043
View 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 Dec 24, 2018
git/yang-zhang.github.io/ds_code/fastai-RNNLearner-getpreds-debug.ipynb
View 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.
View 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 / dropout-scaling.ipynb
Last active Dec 6, 2018
git/yang-zhang.github.io/ds_math/dropout-scaling.ipynb
View dropout-scaling.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.