0

I'm working on a recursive auto-encoder. The neural network takes two 2D images each shaped (28,28,1) and combined to create an input of (28,28,2). They are encoded into a (28,28,1) shape, and decoded back into the original shape (28,28,2). Thus, the encoded form of data can be fed into the auto-encoder for recursive operation.

We can assume that channel 1 is a new image, and channel 2 is previously encoded data. How do I create a loss function that penalises more heavily for mistakes reconstructing channel 2 (as this will carry previously encoded data)?

I am working in Keras, with a Tensorflow back-end.

Alternatively, is there a way to train the network as a complete tree, as opposed to doing it only for single two input - two output blocks at a time?

Harrison Rose
  • 57
  • 1
  • 3

1 Answers1

2

You can separate your decoded (28, 28, 2) back into 2 images as output and use loss_weights to assign a weight of importance. From the documentation:

model.compile(optimizer='rmsprop', loss='binary_crossentropy',
              loss_weights=[1., 0.2])

And yes, all models in Keras are like layers so you can chain them together to construct a tree for example. Then you can train the network in one go and decide whether you would like to share weights etc. However, it could be more difficult to train. I would recommend using the functional API to create these more complex structures so you have more control.

nuric
  • 11,027
  • 3
  • 27
  • 42