0
$\begingroup$

let us assume I have a keras functional model with 2 inputs. My model has two branchs, each branch for each input. The model only uses dense layers. The first input is the data itself (feature vector of the example). The second input is an other vector that is used for modulation. More precisely, the second input is also encoded and multiplied with a deeper representation of the first input. At these stage, both inputs are merged and given to further dense layer to produce a final prediction. Results are good and better as without the second input.

For debugging purposes, I added several outputs to the model.In the end, I have 4 outputs: 1. the final prediction value which is used for loss calucatuon. Additionally, 2. the deep representation of the first input before multiplication, 3. the deep representation of the second input before multiplication, 4. the vector after multiplication of both values.

I use the functional api of keras and added them easily to the output to access them after a prediction and want to look at them. Now I am wondering: does this have any influence on the training? What influence does the additional output values have? Does that means that through the intermediate layer results that I added to the output, that gradients directly from the loss influence at that stage? How can I verify the backward flow of gradients or get a computational graph to verify the models flow?

For optimiazation of the model / learning of parameter, I use tf.GradientTape which gets the loss values and the trainable parameters via model.trainable_variables. These are given to my adam optimizer via the methods apply_gradients().

Thanks for help and any hints about this topic!

$\endgroup$

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.