I implemented a custom layer with a simple trick which computes the variance based on the Var(X) = E(X^2) - E(X)^2 formula. So far, I haven’t noticed any significant slowdowns: https://gist.github.com/amiasato/902fc14afa37a7537386f7b0c5537741 208