Deeplearning - Ai Deeplearning - Ai
Deeplearning - Ai Deeplearning - Ai
DeepLearning.AI makes these slides available for educational purposes. You may not use or
distribute these slides for commercial purposes. You may make copies of these slides and
use or distribute them for educational purposes as long as you cite DeepLearning.AI as the
source of the slides.
X2 Y2
X3
Y3
Y1
X1
X2 Y2
X3
Y3
Y1
X1
X2 Y2
X3
Y3
Encoder
Y1
X1
X2 Y2
X3
Y3
Decoder
Y1
X1
X2 Y2
X3
Y3
X1 Y1
X2 Y2
X3 Y3
Y1
X1
X2 Y2
X3
Y3
Y1
X1
X2 Y2
X3
Y3
Y1
X1
X2 Y2
X3
Y3
Y1
X1
X2 Y2
X3
Y3
Y1
X1
X2 Y2
X3
Y3
encoder = keras.models.Sequential([keras.layers.Dense(2, input_shape=[3])])
autoencoder.compile(loss="mse", optimizer=keras.optimizers.SGD(lr=1.5))
Y1
X1
X2 Y2
X3
Y3
encoder = keras.models.Sequential([keras.layers.Dense(2, input_shape=[3])])
autoencoder.compile(loss="mse", optimizer=keras.optimizers.SGD(lr=1.5))
Y1
X1
X2 Y2
X3
Y3
encoder = keras.models.Sequential([keras.layers.Dense(2, input_shape=[3])])
autoencoder.compile(loss="mse", optimizer=keras.optimizers.SGD(lr=1.5))
Y1
X1
X2 Y2
X3
Y3
encoder = keras.models.Sequential([keras.layers.Dense(2, input_shape=[3])])
autoencoder.compile(loss="mse", optimizer=keras.optimizers.SGD(lr=1.5))
Y1
X1
X2 Y2
X3
Y3
history = autoencoder.fit(X_train, X_train, epochs=200)
history = autoencoder.fit(X_train, X_train, epochs=200)
history = autoencoder.fit(X_train, X_train, epochs=200)
Y1
X1
X2 Y2
X3
Y3
codings = encoder.predict(data)
decodings = decoder.predict(codings)
inputs = tf.keras.layers.Input(shape=(784,))
def simple_autoencoder():
encoder = tf.keras.layers.Dense(units=32, activation='relu')(inputs)
decoder = tf.keras.layers.Dense(units=784, activation='sigmoid')(encoder)
return encoder, decoder
def simple_autoencoder():
encoder = tf.keras.layers.Dense(units=32, activation='relu')(inputs)
decoder = tf.keras.layers.Dense(units=784, activation='sigmoid')(encoder)
return encoder, decoder
def simple_autoencoder():
encoder = tf.keras.layers.Dense(units=32, activation='relu')(inputs)
decoder = tf.keras.layers.Dense(units=784, activation='sigmoid')(encoder)
return encoder, decoder
def simple_autoencoder():
encoder = tf.keras.layers.Dense(units=32, activation='relu')(inputs)
decoder = tf.keras.layers.Dense(units=784, activation='sigmoid')(encoder)
return encoder, decoder
def simple_autoencoder():
encoder = tf.keras.layers.Dense(units=32, activation='relu')(inputs)
decoder = tf.keras.layers.Dense(units=784, activation='sigmoid')(encoder)
return encoder, decoder
def simple_autoencoder():
encoder = tf.keras.layers.Dense(units=32, activation='relu')(inputs)
decoder = tf.keras.layers.Dense(units=784, activation='sigmoid')(encoder)
return encoder, decoder
h1 h1
x2 x2`
h1 h1
h2 x’3 h2
x3 h2 h2
x3`
h3 x’3 h3
h3 h3
x4 x4`
h4 h4
x5 x5`
h1 h1
x2 x2`
h1 h1
h2 x’3 h2
x3 h2 h2
x3`
h3 x’3 h3
h3 h3
x4 x4`
h4 h4
x5 x5`
h1 h1
x2 x2`
h1 h1
h2 x’3 h2
x3 h2 h2
x3`
h3 x’3 h3
h3 h3
x4 x4`
h4 h4
x5 x5`
h1 h1
x2 x2`
h1 h1
h2 x’3 h2
x3 h2 h2
x3`
h3 x’3 h3
h3 h3
x4 x4`
h4 h4
x5 x5`
h1 h1
x2 x2`
h1 h1
h2 x’3 h2
x3 h2 h2
x3`
h3 x’3 h3
h3 h3
x4 x4`
h4 h4
x5 x5`
def deep_autoencoder():
encoder = tf.keras.layers.Dense(units=128, activation='relu')(inputs)
encoder = tf.keras.layers.Dense(units=64, activation='relu')(encoder)
encoder = tf.keras.layers.Dense(units=32, activation='relu')(encoder)
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Reconstructed
Input
Input
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Reconstructed
Input
Input
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Reconstructed
Input
Input
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Reconstructed
Input
Input
Input Conv 2
def encoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=64, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
max_pool_1 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_1)
max_pool_2 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_2)
return max_pool_2
def encoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=64, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
max_pool_1 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_1)
max_pool_2 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_2)
return max_pool_2
def encoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=64, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
max_pool_1 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_1)
max_pool_2 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_2)
return max_pool_2
def encoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=64, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
max_pool_1 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_1)
max_pool_2 = tf.keras.layers.MaxPooling2D(pool_size=(2,2))(conv_2)
return max_pool_2
def bottle_neck(inputs):
bottle_neck = tf.keras.layers.Conv2D(filters=256, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
return conv_3
def decoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=128, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
up_sample_1 = tf.keras.layers.UpSampling2D(size=(2,2))(conv_1)
return conv_3
def decoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=128, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
up_sample_1 = tf.keras.layers.UpSampling2D(size=(2,2))(conv_1)
return conv_3
def decoder(inputs):
conv_1 = tf.keras.layers.Conv2D(filters=128, kernel_size=(3,3),
activation='relu', padding='same')(inputs)
up_sample_1 = tf.keras.layers.UpSampling2D(size=(2,2))(conv_1)
return conv_3
def convolutional_auto_encoder():
inputs = tf.keras.layers.Input(shape=(28, 28, 1,))
encoder_output = encoder(inputs)
decoder_output = decoder(bottleneck_output)
encoder_output = encoder(inputs)
decoder_output = decoder(bottleneck_output)
encoder_output = encoder(inputs)
decoder_output = decoder(bottleneck_output)
encoder_output = encoder(inputs)
decoder_output = decoder(bottleneck_output)
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Training X Training Y
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Training X Training Y
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Training X Training Y
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Training X Training Y
Input Conv 2
Convolutional Auto-Encoders
28 x 28 x 1 28 x 28 x 1
28 x 28 x 64
28 x 28 x 64
14 x 14 x 128 14 x 14 x 128
7 x 7 x 256
Training X Training Y
Input Conv 2
def map_image_with_noise(image, label):
noise_factor = 0.5
image = tf.cast(image, dtype=tf.float32)
image = image / 255.0