Skip to content

Instantly share code, notes, and snippets.

View sksq96's full-sized avatar

Shubham Chandel sksq96

View GitHub Profile
@yuzeh
yuzeh / masked_softmax.py
Last active September 14, 2020 15:17
A PyTorch implementation of a softmax function where support of the underlying categorical distribution is given as input. Useful for, e.g., learning discrete policies where certain actions are known a-priori to be invalid.
# MIT License
#
# Copyright (c) 2018 Yuze Huang ([email protected])
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@thomwolf
thomwolf / AdamW.py
Created July 3, 2018 21:20
Implements Adam algorithm with weight decay fix in PyTorch (paper: https://arxiv.org/abs/1711.05101)
from torch.optim import Optimizer
class AdamW(Optimizer):
"""
Implements Adam algorithm with weight decay fix in PyTorch
Paper: Fixing Weight Decay Regularization in Adam by Ilya Loshchilov, Frank Hutter
https://arxiv.org/abs/1711.05101
"""
def __init__(self, params, lr, b1=0.9, b2=0.999, e=1e-8, l2=0,
vector_l2=False, max_grad_norm=-1, **kwargs):
@eddex
eddex / Install CUDA 10.1 on Ubuntu 18.04.md
Last active August 23, 2024 23:55
How to install CUDA 10.1 on Ubuntu 18.04

How to install CUDA 10.1 on Ubuntu 18.04

A clean installation of Ubuntu 18.04.02 LTS was used.

This gist is an extension to the official docs, adding missing parts and instructions.

2 pre-install actions

follow the pre-installation actions on:

fairseq-train qa_en_small-bin \
--log-interval=10 \
--log-format=json \
--tensorboard-logdir=/users/tom/ed/sp/pretrain/tests/fairseq/bart_en_small/logs \
--seed=1 \
--cpu \
--min-loss-scale=0.0001 \
--model-parallel-size=1 \
--criterion=cross_entropy \