Skip to content

Instantly share code, notes, and snippets.

Avatar

Mirodil Mirodil

View GitHub Profile
View Orthonormal init and LSUV.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gilrosenthal
gilrosenthal / Fast.ai install script
Created Jul 4, 2018
Fast.ai Install on Google Colab
View Fast.ai install script
!pip install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
@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,
@jeremyjordan
jeremyjordan / sgdr.py
Last active Sep 20, 2021
Keras Callback for implementing Stochastic Gradient Descent with Restarts
View sgdr.py
from keras.callbacks import Callback
import keras.backend as K
import numpy as np
class SGDRScheduler(Callback):
'''Cosine annealing learning rate scheduler with periodic restarts.
# Usage
```python
schedule = SGDRScheduler(min_lr=1e-5,
@sbugallo
sbugallo / resnext-101.py
Created Jan 23, 2018
ResNeXt 101 for MRCNN
View resnext-101.py
from keras.layers import Conv2D
from keras.layers import Activation
from keras.layers import Add
from keras.layers import BatchNormalization
from keras.layers import ZeroPadding2D
from keras.layers import MaxPooling2D
def identity_block(input_tensor, kernel_size, filters, stage, block, use_bias=True):
"""
This block is the one with no convolutional layer at its shortcut branch
View 0-bridging-react-native-cheatsheet.md
View classifier_from_little_data_script_1.py
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active Jul 21, 2021
Quick steps of how to create a flame graph using perf
View perf-flame-graph-notes.md

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0