9x25dillon commited on
Commit
60d2826
·
verified ·
1 Parent(s): e45b3d7

Create consensus/topo.py

Browse files
Files changed (1) hide show
  1. consensus/topo.py +2 -1
consensus/topo.py CHANGED
@@ -15,7 +15,8 @@ class TopologicalConsciousness:
15
  def calculate_coherence(self, embeddings: list[np.ndarray]) -> float:
16
  E = np.stack(embeddings, axis=0)
17
  E = self._normalize_rows(E)
18
- K = 0.5 * ((E @ E.T) + (E @ E.T).T) # cosine Gram, symmetrized
 
19
  vals, vecs = eigh(K)
20
  w = np.abs(vecs[:, -1]); w = w / (w.sum() + 1e-12)
21
  M = len(embeddings)
 
15
  def calculate_coherence(self, embeddings: list[np.ndarray]) -> float:
16
  E = np.stack(embeddings, axis=0)
17
  E = self._normalize_rows(E)
18
+ K = E @ E.T
19
+ K = 0.5 * (K + K.T)
20
  vals, vecs = eigh(K)
21
  w = np.abs(vecs[:, -1]); w = w / (w.sum() + 1e-12)
22
  M = len(embeddings)