Why does binarycrossentropy needs an index in a denoising autoencoder?

The loss function needs to return a scalar.

From the definitions of crossentropy and binarycrossentropy, crossentropy includes a sum over the model output, while binarycrossentropy expects a scalar model output.

Try broadcasting binarycrossentropy over the output and summing like this:

loss(x, y) = sum(Flux.binarycrossentropy.(m(x), y)) 
2 Likes