Skip to content

Instantly share code, notes, and snippets.

@tejaskhot
tejaskhot / exp_lr_scheduler.py
Last active April 19, 2022 20:59
exponential learning rate decay in pytorch
def exp_lr_scheduler(optimizer, global_step, init_lr, decay_steps, decay_rate, lr_clip, staircase=True):
"""Decay learning rate by a factor of 0.1 every lr_decay_epoch epochs."""
if staircase:
lr = init_lr * decay_rate**(global_step // decay_steps)
else:
lr = init_lr * decay_rate**(global_step / decay_steps)
lr = max(lr, lr_clip)
if global_step % decay_steps == 0:
print('LR is set to {}'.format(lr))
@karpathy
karpathy / min-char-rnn.py
Last active June 4, 2024 19:24
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@iamtekeste
iamtekeste / Download Google Drive files with WGET
Created July 8, 2015 11:00
Download Google Drive files with WGET
Download Google Drive files with WGET
Example Google Drive download link:
https://docs.google.com/open?id=[ID]
To download the file with WGET you need to use this link:
https://googledrive.com/host/[ID]
Example WGET command: