<jupyter_start><jupyter_text>PROJECT DETAILSName : <NAME> Number : 2k18/IT/018Lab : Deep Learning G2Task : To evaluate model performance with respect to increasinghyper-parameters in a shallow neural network.<jupyter_code># Preparing the dataset
# Setup train and test splits

(x_train, y_train),(x_test,y_test) = mnist.load_data()
x_train_drawing = x_train # X-trainn drawing, is not reshaped and would be used for viewing the images

print("X_Train\n",x_train[0],"\n\n","y_train\n",y_train[0]) # the first number in the dataset is 5
print("X_Train Shape:",x_train.shape,"\n\n","y_train Shape:",y_train.shape)
image_size = 784 # since its 28 X 28
x_train = x_train.reshape(x_train.shape[0],image_size)
x_test = x_test.reshape(x_test.shape[0],image_size)
num_classes = 10
y_train = keras.utils.to_categorical(y_train,num_classes)
y_test = keras.utils.to_categorical(y_test,num_classes)
print(y_train.shape)
print(y_train[0]) # one-hot form
for i in range(64) :

  ax = plt.subplot(8,8,i+1)
  ax.axis('off')
  plt.imshow(x_train_drawing[randint(0,x_train.shape[0])],cmap = 'Greys')<jupyter_output><empty_output><jupyter_text>Layer with 25 Neurons<jupyter_code>model_25 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_25.add(Dense(units = 25,activation = 'sigmoid',input_shape=(image_size,))) 
model_25.add(Dense(units=num_classes,activation='softmax'))
model_25.summary()
model_25.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_25.fit(x_train,y_train,batch_size=128,epochs = 100,verbose=True,validation_split = .1)

lose,accuracy = model_25.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 25 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 50 Neurons<jupyter_code>model_50 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_50.add(Dense(units = 50,activation = 'sigmoid',input_shape=(image_size,))) 
model_50.add(Dense(units=num_classes,activation='softmax'))
model_50.summary()
model_50.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_50.fit(x_train,y_train,batch_size=128,epochs = 100,verbose=True,validation_split = .1)

lose,accuracy = model_50.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 50 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 100 Neurons<jupyter_code>model_100 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_100.add(Dense(units = 100,activation = 'sigmoid',input_shape=(image_size,))) 
model_100.add(Dense(units=num_classes,activation='softmax'))
model_100.summary()
model_100.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_100.fit(x_train,y_train,batch_size=128,epochs = 100,verbose=True,validation_split = .1)

lose,accuracy = model_100.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 100 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 200 Neurons<jupyter_code>model_200 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_200.add(Dense(units = 200,activation = 'sigmoid',input_shape=(image_size,))) 
model_200.add(Dense(units=num_classes,activation='softmax'))
model_200.summary()
model_200.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_200.fit(x_train,y_train,batch_size=128,epochs = 100,verbose=True,validation_split = .1)

lose,accuracy = model_200.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 200 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 500 Neurons<jupyter_code>model_500 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_500.add(Dense(units = 500,activation = 'sigmoid',input_shape=(image_size,))) 
model_500.add(Dense(units=num_classes,activation='softmax'))
model_500.summary()
model_500.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_500.fit(x_train,y_train,batch_size=128,epochs = 10,verbose=True,validation_split = .1) # epochs chaged to 10

lose,accuracy = model_500.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 500 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 1000 Neurons<jupyter_code>model_1000 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_1000.add(Dense(units = 1000,activation = 'sigmoid',input_shape=(image_size,))) 
model_1000.add(Dense(units=num_classes,activation='softmax'))
model_1000.summary()
model_1000.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_1000.fit(x_train,y_train,batch_size=128,epochs = 5,verbose=True,validation_split = .1) # epochs chaged to 10

lose,accuracy = model_1000.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 1000 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 10000 Neurons<jupyter_code>model_10000 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_10000.add(Dense(units = 10000,activation = 'sigmoid',input_shape=(image_size,))) 
model_10000.add(Dense(units=num_classes,activation='softmax'))
model_10000.summary()
model_10000.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_10000.fit(x_train,y_train,batch_size=128,epochs = 5,verbose=True,validation_split = .1) # epochs chaged to 10

lose,accuracy = model_10000.evaluate(x_test,y_test,verbose = True)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model 10000 accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['training','validation'],loc='best')
plt.show()<jupyter_output><empty_output><jupyter_text>Layer with 1,00,000 Neurons<jupyter_code>model_100000 = Sequential() # feed forward - backward propagate
# eager execution enabled - session online

model_100000.add(Dense(units = 100000,activation = 'sigmoid',input_shape=(image_size,))) 
model_100000.add(Dense(units=num_classes,activation='softmax'))
model_100000.summary()
model_100000.compile(optimizer="sgd",loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model_100000.fit(x_train,y_train,batch_size=128,epochs = 2,verbose=True,validation_split = .1) # epochs chaged to 10

lose,accuracy = model_100000.evaluate(x_test,y_test,verbose = True)<jupyter_output>Epoch 1/2
422/422 [==============================] - 374s 886ms/step - loss: 5.3072 - accuracy: 0.8224 - val_loss: 0.1207 - val_accuracy: 0.9677
Epoch 2/2
183/422 [============>.................] - ETA: 3:21 - loss: 0.0597 - accuracy: 0.9848
{'fraction_non_alphanumeric': 0.15605095541401273, 'fraction_numerical': 0.05286624203821656, 'mean_word_length': 8.925410872313527, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '535572', 'license': 'MIT', 'n_tokens_mistral': 3114, 'n_tokens_neox': 2717, 'n_words': 413, 'path': 'Experiment 4/code.ipynb', 'repo_name': 'inofficialamanjha/Deep-Learning-Tutorial---Keras', 'size': '7856'}