October 2017
Intermediate to advanced
330 pages
7h 7m
English
import numpy as npfrom matplotlib import pyplot as pltimport scipy.iofrom keras.models import Sequentialfrom keras.layers.core import Densefrom keras.optimizers import Adam
mat = scipy.io.loadmat('./data/train_32x32.mat')mat = mat['X']b, h, d, n = mat.shape
# Grayscaleimg_gray = np.zeros(shape =(n, b * h))def rgb2gray(rgb): return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])for i in range(n): #Convert to greyscale img = rgb2gray(mat[:,:,:,i]) img = img.reshape(1, 1024) img_gray[i,:] = img# NormalizeX_train = img_gray/255.
img_size = X_train.shape[1] ...
Read now
Unlock full access