Autoencoders
An autoencoder is a type of neural network used to learn efficient codings of input data. It consists of an encoder that compresses the data into a latent space representation, and a decoder that reconstructs the original data from this representation.
Key Concepts
- Encoder: Maps input \\(x\\) to latent representation \\(z\\).
- Decoder: Reconstructs \\(\\hat{x}\\) from \\(z\\).
- Loss Function: Typically Mean Squared Error between \\(x\\) and \\(\\hat{x}\\).
Simple Autoencoder in TensorFlow/Keras
import tensorflow as tf
from tensorflow.keras import layers, models
# Encoder
input_img = layers.Input(shape=(28, 28, 1))
x = layers.Flatten()(input_img)
encoded = layers.Dense(64, activation='relu')(x)
# Decoder
x = layers.Dense(784, activation='sigmoid')(encoded)
decoded = layers.Reshape((28,28,1))(x)
autoencoder = models.Model(input_img, decoded)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.summary()