gradient calculation rewritten

It is much faster to calculate the gradients based on the inputs and the
noise values rather than reconstruction outputs and using these and the
inputs. It cuts the computational performance into half.