Skip to content

Instantly share code, notes, and snippets.

View vaibhavcodes's full-sized avatar

Vaibhav Khandelwal vaibhavcodes

View GitHub Profile
@vaibhavcodes
vaibhavcodes / numpy.ipynb
Created August 18, 2019 14:29
Numpy.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_import_library.py
Created June 24, 2020 16:32
Code of LeNet-5 Architecture- Libraries to be imported
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Conv2D, AvgPool2D, Flatten, Dense
from keras.optimizers import Adam
from keras.utils import to_categorical
from keras.utils.vis_utils import plot_model
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_dataset_splitting.py
Created June 24, 2020 17:08
LeNet-5_Architecture - Splitting of Dataset into train and test
(train_x, train_y), (test_x, test_y) = mnist.load_data()
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_shape_of_train_and_test.py
Created June 24, 2020 17:12
LeNet-5_Architecture train and test split
print("The size of train_x is: {}".format(train_x.shape))
print("The size of train_y is: {}".format(train_y.shape))
print("The size of test_x is: {}".format(test_x.shape))
print("The size of test_y is: {}".format(test_y.shape))
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_reshaping_image.py
Created June 24, 2020 17:20
LeNet-5 Architecture reshaping of image
train_x = train_x.reshape(train_x.shape[0], 28, 28, 1)
test_x = test_x.reshape(test_x.shape[0], 28, 28, 1)
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_Normalization.py
Created June 24, 2020 17:22
LeNet-5 Architecture Normalization
train_x = train_x/255.0
test_x = test_x/255.0
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_OneHotEncoding.py
Created June 24, 2020 17:29
LeNet-5 Architecture One Hot Encoding
train_y = to_categorical(train_y, num_classes=10)
test_y = to_categorical(test_y, num_classes=10)
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_Model_Creation.py
Created June 24, 2020 17:32
LeNet-5 Architecture Model Creation
# Instanciate an empty model
model = Sequential()
# Adding a Convolution Layer C1
# Input shape = N = (28 x 28)
# No. of filters = 6
# Filter size = f = (5 x 5)
# Padding = P = 0
# Strides = S = 1
# Size of each feature map in C1 is (N-f+2P)/S +1 = 28-5+1 = 24
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_Compilation_and_Fitting_of_model.py
Created June 24, 2020 17:37
LeNet-5 Architecture Compilation and Fitting of model
model.compile(loss='categorical_crossentropy', optimizer=Adam(), metrics=['accuracy'])
model.fit(train_x, train_y, batch_size=128, epochs=20, verbose=1, validation_data=(test_x, test_y))
@vaibhavcodes
vaibhavcodes / LeNet-5_Architecture_loss_and_accuracy.py
Created June 24, 2020 17:41
LeNet-5 Architecture loss and accuracy
score = model.evaluate(test_x, test_y)
print('Test Loss:', score[0])
print('Test accuracy:', score[1])