This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def count_conv_params_flops(conv_layer, verbose=1): | |
# out shape is n_cells_dim1 * (n_cells_dim2 * n_cells_dim3) | |
out_shape = conv_layer.output.shape.as_list() | |
n_cells_total = np.prod(out_shape[1:-1]) | |
n_conv_params_total = conv_layer.count_params() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Code Snippet for counting FLOPs of a model. | |
Not final version, it will be updated to improve the usability. | |
""" | |
import os.path | |
import tempfile | |
import tensorflow as tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from keras import backend as K | |
from keras.models import Sequential | |
from keras.layers.core import Dense, Dropout, Activation, Flatten | |
from keras.layers.convolutional import Convolution2D, MaxPooling2D | |
from keras.preprocessing.image import ImageDataGenerator | |
from sklearn.metrics import classification_report, confusion_matrix | |
#Start | |
train_data_path = 'F://data//Train' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import numpy as np | |
import pdb | |
img_width, img_height = 300, 300 | |
box_configs = [ | |
{'layer_width': 38, 'layer_height': 38, 'num_prior': 3, 'min_size': 30.0, | |
'max_size': None, 'aspect_ratios': [1.0, 2.0, 1/2.0]}, | |
{'layer_width': 19, 'layer_height': 19, 'num_prior': 6, 'min_size': 60.0, | |
'max_size': 114.0, 'aspect_ratios': [1.0, 1.0, 2.0, 1/2.0, 3.0, 1/3.0]}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from scipy.ndimage.interpolation import map_coordinates | |
from scipy.ndimage.filters import gaussian_filter | |
def elastic_transform(image, alpha, sigma, random_state=None): | |
"""Elastic deformation of images as described in [Simard2003]_. | |
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for | |
Convolutional Neural Networks applied to Visual Document Analysis", in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Title : Pandas Row Shuffler | |
Author : Felan Carlo Garcia | |
''' | |
import numpy as np | |
import pandas as pd | |
def shuffler(filename): | |
df = pd.read_csv(filename, header=0) | |
# return the pandas dataframe |