@jeremy I used a data set of faces to enhance my unsupervised learning with 40 people and 450 images total.
I moved about 30 to the test set and trained on the rest. I was getting about 50% loss in the beginning to so changed the optimizer to sgd and loss to mse and after running about 80 epochs I was able to come down to 1% accuracy.
input_img = Input(shape=(3, 174, 174))
x = Convolution2D(16, 3, 3, activation='relu', border_mode='same')(input_img)
x = MaxPooling2D((2, 2), border_mode='same')(x)
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
x = MaxPooling2D((2, 2), border_mode='same')(x)
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
encoded = MaxPooling2D((2, 2), border_mode='same')(x)
# at this point the representation is (8, 4, 4) i.e. 128-dimensional
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(encoded)
x = UpSampling2D((2, 2))(x)
x = Convolution2D(8, 2, 2, activation='relu', border_mode='same')(x)
x = UpSampling2D((2, 2))(x)
x = Convolution2D(16, 2, 2, activation='relu')(x)
x = UpSampling2D((2, 2))(x)
decoded = Convolution2D(3, 3, 3, activation='sigmoid', border_mode='same')(x)
autoencoder = Model(input_img, decoded)
autoencoder.compile(optimizer='sgd', loss='mean_squared_error')
I couldnt draw the images for some reason. They are showing up black. I am not sure why.
decoded_imgs = autoencoder.predict(tst_data)
n = 10
plt.figure(figsize=(20, 4))
for i in range(n):
# display original
if i==0:
i = 1
ax = plt.subplot(2, n+1, i)
newdata = np.reshape(tst_data[i], (len(tst_data[i]), 174, 174))
newdata = np.rollaxis(newdata, 0, 3)
plt.imshow(newdata)
plt.gray()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
# display reconstruction
ax = plt.subplot(2, n, i + n)
decdata = np.reshape(decoded_imgs[i], (len(decoded_imgs[i]), 174, 174))
decdata = np.rollaxis(decdata, 0, 3)
plt.imshow(decdata)
plt.gray()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.show()
I am not sure if i am making some major mistakes… The data set is too small to be so highly accurate…
what do you think?