Create consensus/topo.py
Browse files- 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 =
|
|
|
|
| 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)
|