text
stringlengths
0
4.99k
Epoch 2/50
469/469 [==============================] - 21s 45ms/step - loss: 0.0719 - val_loss: 0.0698
Epoch 3/50
469/469 [==============================] - 22s 47ms/step - loss: 0.0695 - val_loss: 0.0682
Epoch 4/50
469/469 [==============================] - 23s 50ms/step - loss: 0.0684 - val_loss: 0.0674
Epoch 5/50
469/469 [==============================] - 24s 51ms/step - loss: 0.0676 - val_loss: 0.0669
Epoch 6/50
469/469 [==============================] - 26s 55ms/step - loss: 0.0671 - val_loss: 0.0663
Epoch 7/50
469/469 [==============================] - 27s 57ms/step - loss: 0.0667 - val_loss: 0.0660
Epoch 8/50
469/469 [==============================] - 26s 56ms/step - loss: 0.0663 - val_loss: 0.0657
Epoch 9/50
469/469 [==============================] - 28s 59ms/step - loss: 0.0642 - val_loss: 0.0639
Epoch 21/50
469/469 [==============================] - 28s 60ms/step - loss: 0.0642 - val_loss: 0.0638
Epoch 22/50
469/469 [==============================] - 29s 62ms/step - loss: 0.0632 - val_loss: 0.0629
Epoch 38/50
397/469 [========================>.....] - ETA: 4s - loss: 0.0632
Let's predict on our test dataset and display the original image together with the prediction from our autoencoder.
Notice how the predictions are pretty close to the original images, although not quite the same.
predictions = autoencoder.predict(test_data)
display(test_data, predictions)
png
Now that we know that our autoencoder works, let's retrain it using the noisy data as our input and the clean data as our target. We want our autoencoder to learn how to denoise the images.
autoencoder.fit(
x=noisy_train_data,
y=train_data,
epochs=100,
batch_size=128,
shuffle=True,
validation_data=(noisy_test_data, test_data),
)
Epoch 1/100
469/469 [==============================] - 28s 59ms/step - loss: 0.1027 - val_loss: 0.0946
Epoch 2/100
469/469 [==============================] - 27s 57ms/step - loss: 0.0942 - val_loss: 0.0924
Epoch 3/100
469/469 [==============================] - 27s 58ms/step - loss: 0.0925 - val_loss: 0.0913
Epoch 4/100
469/469 [==============================] - 28s 60ms/step - loss: 0.0915 - val_loss: 0.0905
Epoch 5/100
469/469 [==============================] - 31s 66ms/step - loss: 0.0908 - val_loss: 0.0897
Epoch 6/100
469/469 [==============================] - 30s 64ms/step - loss: 0.0902 - val_loss: 0.0893
Epoch 7/100
469/469 [==============================] - 28s 60ms/step - loss: 0.0897 - val_loss: 0.0887
Epoch 8/100
469/469 [==============================] - 31s 66ms/step - loss: 0.0872 - val_loss: 0.0867
Epoch 19/100
469/469 [==============================] - 30s 64ms/step - loss: 0.0860 - val_loss: 0.0854
Epoch 35/100
469/469 [==============================] - 32s 68ms/step - loss: 0.0854 - val_loss: 0.0849
Epoch 52/100
469/469 [==============================] - 28s 60ms/step - loss: 0.0851 - val_loss: 0.0847
Epoch 68/100
469/469 [==============================] - 31s 66ms/step - loss: 0.0851 - val_loss: 0.0848
Epoch 69/100
469/469 [==============================] - 31s 65ms/step - loss: 0.0849 - val_loss: 0.0847
Epoch 84/100
469/469 [==============================] - 29s 63ms/step - loss: 0.0848 - val_loss: 0.0846
<tensorflow.python.keras.callbacks.History at 0x7fbb195a3a90>
Let's now predict on the noisy data and display the results of our autoencoder.
Notice how the autoencoder does an amazing job at removing the noise from the input images.
predictions = autoencoder.predict(noisy_test_data)
display(noisy_test_data, predictions)
png
Data augmentation with CutMix for image classification on CIFAR-10.
Introduction
CutMix is a data augmentation technique that addresses the issue of information loss and inefficiency present in regional dropout strategies. Instead of removing pixels and filling them with black or grey pixels or Gaussian noise, you replace the removed regions with a patch from another image, while the ground truth l...
It's implemented via the following formulas:
where M is the binary mask which indicates the cutout and the fill-in regions from the two randomly drawn images and λ (in [0, 1]) is drawn from a Beta(α, α) distribution
The coordinates of bounding boxes are:
which indicates the cutout and fill-in regions in case of the images. The bounding box sampling is represented by:
where rx, ry are randomly drawn from a uniform distribution with upper bound.
Setup
import numpy as np