We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 172a68d commit b8015fcCopy full SHA for b8015fc
1 file changed
ngclearn/utils/analysis/effective_dim.py
@@ -1,6 +1,16 @@
1
from jax import numpy as jnp
2
3
-def participation_ratio(Z):
+def participation_ratio(latent_codes):
4
+ """
5
+ Calculates the participation ratio coefficient for a set of latent codes
6
+
7
+ Args:
8
+ latent_codes: a set of (N x D) latent code vectors (one row per vector code)
9
10
+ Returns:
11
+ scalar measurement of the effective dimension
12
13
+ Z = latent_codes
14
Zc = Z - Z.mean(axis=0, keepdims=True)
15
cov = (Zc.T @ Zc) / (Zc.shape[0] - 1)
16
@@ -9,3 +19,4 @@ def participation_ratio(Z):
19
cov2_tr = jnp.trace(cov @ cov)
20
21
return tr2_cov / cov2_tr if cov2_tr > 0 else float("nan")
22
0 commit comments