I am implementing an autoencoder using the Fashion MNIST dataset. The code for the encoder-
class MNISTClassifier(Model):
def __init__(self):
super(MNISTClassifier, self).__init__()
self.encoder = Sequential([
layers.Dense(128, activation = "relu"),
layers.Dense(64, activation = "relu"),
layers.Dense(32, activation = "relu")
])
self.decoder = Sequential([
layers.Dense(64, activation = "relu"),
layers.Dense(128, activation= "relu"),
layers.Dense(784, activation= "relu")
])
def call(self, x):
encoded = self.encoder(x)
decoded = self.decoder(encoded)
return decoded
autoencoder = MNISTClassifier()
now I want to train an SVM classifier on the image representations extracted from the above autoencoder mean Once the above fully-connected autoencoder is trained, for each image, I want to extract the 32- dimensional hidden vector (the output of the ReLU after the third encoder layer) as the image representation and then train a linear SVM classifier on the training images of fashion mnist based on the 32- dimensional features.
How to extract the output 32- dimensional hidden vector?
enc_outputs = classifier.encoder.predict( images )whereclassifieris an instance ofMNISTClassifier.