Gabriele commited on
Commit ·
4842da4
1
Parent(s): cf63d64
PCA visualization: add whitening and sigmoid
Browse files
README.md
CHANGED
|
@@ -96,7 +96,8 @@ from sklearn.decomposition import PCA
|
|
| 96 |
|
| 97 |
spatial = out.patch_tokens.reshape(1, 32, 32, 1536)
|
| 98 |
feat = spatial[0].detach().numpy().reshape(-1, 1536)
|
| 99 |
-
rgb = PCA(n_components=3).fit_transform(feat).reshape(32, 32, 3)
|
|
|
|
| 100 |
print(rgb.shape) # (32, 32, 3) — PCA of patch features as RGB
|
| 101 |
```
|
| 102 |
|
|
|
|
| 96 |
|
| 97 |
spatial = out.patch_tokens.reshape(1, 32, 32, 1536)
|
| 98 |
feat = spatial[0].detach().numpy().reshape(-1, 1536)
|
| 99 |
+
rgb = PCA(n_components=3, whiten=True).fit_transform(feat).reshape(32, 32, 3)
|
| 100 |
+
rgb = 1 / (1 + np.exp(-2.0 * rgb)) # sigmoid for [0, 1] range with good contrast
|
| 101 |
print(rgb.shape) # (32, 32, 3) — PCA of patch features as RGB
|
| 102 |
```
|
| 103 |
|