Skip to content

Instantly share code, notes, and snippets.

Mirodil Mirodil

Block or report user

Report or block Mirodil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Mirodil
Mirodil / find_learning_rate.py
Created Dec 10, 2018
PyTorch Learning Rate Finder
View find_learning_rate.py
def find_learning_rate(model, data_loader, criterion, lr:tuple=(1e-7, 1), epochs:int=1):
history = []
min_lr, max_lr = lr
num_batches = epochs * len(data_loader)
last_avg_loss, i, beta = 0, 0, 0.98
# preserve initial state
initial_weights = './temp.model'
torch.save(model.state_dict(), initial_weights)
@Mirodil
Mirodil / LearningRateFinder.py
Last active Dec 14, 2018
LearningRateFinder for keras
View LearningRateFinder.py
class LearningRateFinder(Callback):
'''
This callback implements a learning rate finder(LRF)
The learning rate is constantly increased during training.
On training end, the training loss is plotted against the learning rate.
One may choose a learning rate for a model based on the given graph,
selecting a value slightly before the minimal training loss.
# Example
lrf = LearningRateFinder([0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05])
model.fit(x_train, y_train, epochs=1, batch_size=128, callbacks=[lrf])
@Mirodil
Mirodil / FileListIterator.py
Last active May 10, 2018
FileListIterator for keras
View FileListIterator.py
import numpy as np
from keras import backend as K
from keras.preprocessing.image import Iterator, load_img, img_to_array
class FileListIterator(Iterator):
"""Iterator capable of reading images from an array of the filenames.
# Arguments
filenames: Path to the directory to read images from.
Each subdirectory in this directory will be
considered to contain images from one class,
@Mirodil
Mirodil / config.js
Last active Jun 19, 2017
AngularJs: OAuth 2.0 Refresh Token
View config.js
(function(){
angular.module('app', [])
.config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push(['$q', '$window', '$timeout', '$injector', function ($q, $window, $timeout, $injector) {
var $login, $http, $auth;
$timeout(function () {
$login = $injector.get('$login');
$http = $injector.get('$http');
$auth = $injector.get('$auth');
You can’t perform that action at this time.