Skip to content

Commit 05eeea2

Browse files
author
Manthan Thakker
authored
Added Comments to Deep Neural Networks with Keras
Added Comments to Deep Neural Networks with Keras
1 parent 7d02636 commit 05eeea2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

DeepNeuralNetPython/NeuralNetworkWithKeras.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from keras.optimizers import RMSprop
66
import pandas as pd
77

8+
## 1. Import File
89
data = pd.read_csv("/Users/trailbrazer/Desktop/udemy/DataScience-Python3/mammographic_masses.data.txt", na_values=['?'],
910
header=None)
1011

12+
## Preprocessing using Pandas
1113
data.dropna(inplace=True)
1214

1315
trainingData = data.iloc[:700, 0:4]
@@ -18,26 +20,35 @@
1820

1921
(mnist_train_images, mnist_train_labels), (mnist_test_images, mnist_test_labels) = (trainingData, trainingLabel), (testingData, testingLabel)
2022

23+
#Categorical Labels: For 0 and 1 would be 2. Number of Categories
2124
train_labels = keras.utils.to_categorical(mnist_train_labels, 2)
2225
test_labels = keras.utils.to_categorical(mnist_test_labels, 2)
2326

27+
# Model Boiler Plate from Keras, TensorFlow
2428
model = Sequential()
29+
#Input Layer Must match the input features
2530
model.add(Dense(5, activation='relu', input_shape=(4,)))
2631
model.add(Dense(12, activation='relu'))
2732
model.add(Dense(2, activation='softmax'))
33+
#Output Categories = 2 must match the number of categories
34+
#Activation Function = Relu, Softmax is nothing but determining what ouput => classifier
2835

36+
# Model Sumaary
2937
model.summary()
3038

3139
model.compile(loss='categorical_crossentropy',
3240
optimizer=RMSprop(),
3341
metrics=['accuracy'])
3442

43+
# Start the training
3544
history = model.fit(trainingData, train_labels,
3645
batch_size=100,
3746
epochs=1000,
3847
verbose=2,
3948
validation_data=(testingData, test_labels))
4049

50+
#Evaluates the prediction
4151
score = model.evaluate(mnist_test_images, test_labels, verbose=0)
52+
# Accuracy and loss
4253
print('Test loss:', score[0])
4354
print('Test accuracy:', score[1])

0 commit comments

Comments
 (0)