This file contains hidden or 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 | |
n_classes = 10 | |
class_matrix = np.eye(n_classes) | |
""" | |
class_matrix should be obtained as below: | |
array([[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0], |
This file contains hidden or 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 | |
""" | |
In this gist, I demonstrate the simple ways to | |
convert between 2 colorspace representation of images | |
mutually(RGB, BGR). | |
""" | |
CONVERSION_ORDER = [2, 1, 0] | |
def convert_channel(img): |
This file contains hidden or 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
datagen = ImageDataGenerator( | |
featurewise_center=True, # set input mean to 0 over the dataset | |
samplewise_center=False, # set each sample mean to 0 | |
featurewise_std_normalization=True, # divide inputs by std of the dataset | |
samplewise_std_normalization=False, # divide each input by its std | |
zca_whitening=False, # apply ZCA whitening | |
rotation_range=20, # randomly rotate images in the range (degrees, 0 to 180) | |
width_shift_range=0.2, # randomly shift images horizontally (fraction of total width) | |
height_shift_range=0.2, # randomly shift images vertically (fraction of total height) | |
horizontal_flip=True, # randomly flip images |
This file contains hidden or 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.preprocessing.image import ImageDataGenerator,standardize,random_transform | |
# input generator with standardization on | |
datagenX = ImageDataGenerator( | |
featurewise_center=True, | |
featurewise_std_normalization=True, | |
featurewise_standardize_axis=(0, 2, 3), | |
rotation_range=180, | |
width_shift_range=0.2, | |
height_shift_range=0.2, | |
horizontal_flip=True, |
This file contains hidden or 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
https://keras.io/preprocessing/image/ |
This file contains hidden or 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
#1. Install libstdc++6 | |
sudo apt-get install libstdc++6 | |
#2. Copy to envs/tensorflow/bin/../lib/ | |
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /home/username/anaconda/envs/tensorflow/bin/../lib/ |
This file contains hidden or 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.models import Sequential | |
from keras.layers import Dense | |
from keras.utils.io_utils import HDF5Matrix | |
import numpy as np | |
def create_dataset(): | |
import h5py | |
X = np.random.randn(200,10).astype('float32') | |
y = np.random.randint(0, 2, size=(200,1)) | |
f = h5py.File('test.h5', 'w') |
This file contains hidden or 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
Warning message: Duplicate key in file "/home/username/.matplotlib/matplotlibrc", line #2 | |
>>> Solution: | |
Just go to the file "/home/username/.matplotlib/matplotlibrc" and | |
Remove the duplicate key |
This file contains hidden or 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
ssh-keygen - t rsa |
This file contains hidden or 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
## Download file from the url | |
https://www.anaconda.com/download/#macos | |
## Run the graphical installer | |
## Install Tensorflow version 1.6 | |
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.6.0-py3-none-any.whl | |
## Install Keras | |
pip install keras |