Thursday, 14 October 2021

How to randomly set inputs to zero in keras during training autoencoder (callback)?

I am training 2 autoencoders with 2 separate input paths jointly and I would like to randomly set one of the input paths to zero.

I use tensorflow with keras backend (functional API).

I am computing a joint loss (sum of two losses) for backpropagation.

A -> A' & B ->B'

loss => l2(A,A')+l2(B,B')

networks taking A and B are connected in latent space. I would like to randomly set A or B to zero and compute the loss only on the corresponding path, meaning if input path A is set to zero loss be computed only by using outputs of only path B and vice versa; e.g.:

0 -> A' & B ->B'

loss: l2(B,B')

How do I randomly set input path to zero? How do I write a callback which does this?



from How to randomly set inputs to zero in keras during training autoencoder (callback)?

No comments:

Post a Comment