<jupyter_start><jupyter_text>Digit Classification of MNIST dataset after dimensionality reduction from 784 to 32 using Auto-Encoders  Validation Accuracy ~ 84%<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import theano
from keras.models import Sequential,Model,load_model
from keras.layers import Dense,Activation,Dropout
from keras.utils import np_utils
x = pd.read_csv('./train.csv')
X = np.array(x)
x = X[:,1:]
y = X[:,0]
print x.shape,y.shape
X = x.reshape((X.shape[0], 1, 28, 28))
print X.shape
encoder = load_model('./enc_32d.h5')
X_enc = encoder.predict(X)
print X_enc.shape
X_enc = (X_enc - X_enc.mean()/X_enc.std())
x_train = X_enc[:30000,:]
x_crossval = X_enc[30000:,:]
y = np_utils.to_categorical(y)
y_train = y[:30000]
y_crossval = y[30000:]
print x_train.shape,x_crossval.shape,y_train.shape,y_crossval.shape
model = Sequential()

model.add(Dense(16, input_dim=32))
model.add(Activation('relu'))
model.add(Dropout(0.35))
model.add(Dense(10))
model.add(Activation('softmax'))

model.summary()

model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
hist = model.fit(x_train,y_train,
                 nb_epoch = 100,
                 shuffle = True,
                 batch_size = 256,
                 validation_data=(x_crossval, y_crossval))
plt.plot(hist.history['val_loss'], color ='b')
plt.plot(hist.history['loss'], color='r')
plt.plot(hist.history['val_acc'], color ='black')
plt.plot(hist.history['acc'], color ='g')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15197956577266922, 'fraction_numerical': 0.03384418901660281, 'mean_word_length': 5.145098039215687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '345311', 'license': 'MIT', 'n_tokens_mistral': 628, 'n_tokens_neox': 580, 'n_words': 116, 'path': '32_Dimensions/AUTO_ENCODER/auto_encoder_classification.ipynb', 'repo_name': 'vasu-dev/ML-Dimensionality-Reduction', 'size': '1566'}