Search code examples
pythontensorflowsupervised-learningunsupervised-learningautoencoder

Using weights from Autoencoder to initialize neural network in tensorflow


I built an Autoencoder using Python and Tensorflow. To build the Autoencoder I used the Tensorflow tutorial on how to build an Autoencoder to read the MNIST Data set on handwritten digits. I used it to find features of CGRA compositions.

So far I restructured the Code for the Autoencoder in a way that I can use it on my own data. I found features and already managed to reconstruct the Input, up to a certain error. NOW, I am trying to use the Autoencoders weights, to initialize a Neural Network with parameters similiar to the encoder part of my Autoencoder. Then, add one extra Layer with a single neuron and a linear activation function to perform Regression Analysis(or basically supervised learning).

So my question is: How do I initialize a neural network with specific weights (not random) using tensorflow?

I'd be grateful for any kind of help. Links to Tutorials or other links to other Threads.

Tahnks in Advance!


Solution

  • When you build tf.Variable, the first argument is an initial_value.

    https://www.tensorflow.org/api_docs/python/state_ops/variables#Variable.init

    You can provide any Tensor you like to initialize the variables, not just, say, random initialization.

    Another option is you can assign values to the variables after construction, if you find that easier.

    Hope that helps!