Skip to main content

I am implementing an autoencoder using the Fashion MnsitMNIST 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()
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()

How to extract the output 32- dimensional hidden vector??

Thanks in Advance!!!!!!!!!!!!

I am implementing an autoencoder using the Fashion Mnsit 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()

How to extract the output 32- dimensional hidden vector??

Thanks in Advance!!!!!!!!!!!!

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()

How to extract the output 32- dimensional hidden vector?

edited title
Link

How to extract the hidden vector (the output of a hiddenthe ReLU after the third encoder layer from autoencoder using Tensorflow?) as the image representation

Source Link

How to extract the output of a hidden layer from autoencoder using Tensorflow?

I am implementing an autoencoder using the Fashion Mnsit 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??

Thanks in Advance!!!!!!!!!!!!