2
$\begingroup$

I have read about auto encoder. Understood what is encoding part, and decoding part, and the latent space. Now, i tried to implement this in keras. Below is the code.

iLayer = Input ((784,))
layer1 = Dense(128, activation='relu' ) (iLayer)
layer2 = Dense(64, activation='relu') (layer1)
layer3 = Dense(28, activation ='relu') (layer2)
layer4 = Dense(64, activation='relu') (layer3)
layer5 = Dense(128, activation='relu' ) (layer4)
layer6 = Dense(784, activation='softmax' ) (layer5)
model = Model (iLayer, layer6)
model.compile(loss='binary_crossentropy', optimizer='adam')

(trainX, trainY), (testX, testY) =  mnist.load_data()
print ("shape of the trainX", trainX.shape)
trainX = trainX.reshape(trainX.shape[0], trainX.shape[1]* trainX.shape[2])
print ("shape of the trainX", trainX.shape)
model.fit (trainX, trainX, epochs=5, batch_size=100)

As simple as that, i have a 6 dense layers. I am still able see that the output image is closer to the input image.

From blurred to deblurred conversion, i can have few dense layers like the above (Basically a simple neural network) and get the inputs de-blured. In that cause, why autoencoder is very famous for de-blurring? Am I missing any core part of this auto encoder?.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.