Hi en!



 en_tetteh:

How do I compute geometric mean?


You can calculate the geometric mean directly.  Suppose that you
have the weights and/or biases whose geometric mean you want
in a single tensor, w.  Then:
geom_mean = w.prod()**(1 / w.numel())

Note, it might be preferable to perform the calculation in log-space:
geom_mean = w.log().mean().exp()

(The geometric mean only makes sense – for some definition of
“makes sense” – if the values are all strictly positive.  As you can
see, both the fractional power in the direct-space calculation and
the log() in the log-space calculation will fail for negative values.)
Best.
K. Frank