0
$\begingroup$

I wanted to create an encoder, which is the first part of an autoencoder. I do not want to build the whole autoencoder but rather wanted to test whether my mobile device can support running an encoder and encoding some images on a trained TensorFlow model.

But I am having some problems. I found some code online to describe an autoencoder here. My aim is to use the encoder separately to "compress" images. Here is my code. So know I want to convert the encoded variable to a vector format. Can anyone provide a suitably easy solution to accomplish that?

By compressing Images, I mean I just want their vector representation generated by the encoder which can later be decoded. So basically I want it to print its latent space/the encoded variable. The catch is that it should be in a vector representation. The reason is that right know it's shape is (None, 32) which cannot be used for further processing by TensorFlow. So, any ideas?

$\endgroup$
6
  • $\begingroup$ If you look at the code you linked you have an Autoencoder model, which basically take the input encodes it and decodes it. If you want to remove the decoding phase declare a new object of type Decoder and call it with the same input as the Autoencoder. $\endgroup$
    – razvanc92
    Apr 22 '20 at 11:24
  • $\begingroup$ @razvanc92 I have figured that out (I finally found something on the internet) but now the problem is different, so I am changing the whole question by scratch... $\endgroup$
    – neel g
    Apr 22 '20 at 11:26
  • $\begingroup$ I just wrote a small example if you still need it you can access it here: colab.research.google.com/drive/… $\endgroup$
    – razvanc92
    Apr 22 '20 at 11:31
  • $\begingroup$ Thanx, but I just found out that I do not need something as complex as an encoder. A simple dense layer should be enough to test the processing capacity of my device. So could you help me with the updated problem? $\endgroup$
    – neel g
    Apr 22 '20 at 11:34
  • $\begingroup$ I've modified my previous link to fit your needs. The ? in the shape comes from batches, you can process multiple images at the same time, but if you know in advance how many you're going to process you can just use the batch_shape instead of the shape parameter when defining a dense layer. $\endgroup$
    – razvanc92
    Apr 22 '20 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.