Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
yang-zhang / cross-entropy.ipynb
Last active February 5, 2023 00:25
Cross entropy implementation in pytorch
View cross-entropy.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 / pytorch-losses-in-plain-python.ipynb
Last active December 21, 2022 07:14
git/yang-zhang.github.io/ds_code/pytorch-losses-in-plain-python.ipynb
View pytorch-losses-in-plain-python.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 / multi-face.ipynb
Last active February 28, 2022 18:46
Multi-task Deep Learning Experiment using fastai Pytorch
View multi-face.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View fashion_retrieval.md
@yang-zhang
yang-zhang / binary_cross_entropy_with_logits.ipynb
Created October 16, 2018 20:46
binary cross entropy implementation in pytorch
View binary_cross_entropy_with_logits.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_ml_course_notes.md
Last active December 27, 2020 20:55
fast.ai machine learning course notes
View fastai_ml_course_notes.md
@yang-zhang
yang-zhang / boilerplates.md
Last active July 4, 2020 12:51
boilerplates
View boilerplates.md
  • 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
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 January 20, 2020 14:44
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