Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sharanry committed Oct 29, 2024
1 parent 3d04814 commit 2c72071
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ We initialize a linear probe with the same number of outputs as classes in the e
```python
from probe_lens.probes import LinearProbe
X, y = next(iter(dataloader))
probe = LinearProbe(X.shape[1], y.shape[1], class_names=spelling_task.get_classes())
probe = LinearProbe(X.shape[1], y.shape[1], class_names=spelling_task.get_classes(), device=DEVICE)
```

#### Train probe
Expand All @@ -58,6 +58,7 @@ We use the `visualize_performance` method to visualize the performance of the pr
```python
plot = probe.visualize_performance(dataloader)
```
![Confusion Matrix](confusion_matrix.png)


## Roadmap
Expand All @@ -81,3 +82,8 @@ plot = probe.visualize_performance(dataloader)
- [ ] Add more visualization experiments
- [ ] ... ?

### Documentation
- [ ] Add docstrings
- [ ] Add tutorials
- [ ] Reproduce experiments from major papers (SAE-Spelling, etc.)

Binary file added confusion_matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions probe_lens/probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ def visualize_performance(

accuracy = accuracy_score(gts.cpu(), preds.cpu())
f2_score = fbeta_score(gts.cpu(), preds.cpu(), beta=2, average="weighted")

cm = confusion_matrix(gts.cpu(), preds.cpu())
plt.figure(figsize=(10, 7))
_class_names = (
self.class_names
if self.class_names
else [str(i) for i in range(cm.shape[0])]
)
plt.figure(figsize=(10, 7))
sns.heatmap(
cm,
annot=True,
Expand Down

0 comments on commit 2c72071

Please sign in to comment.