Skip to content

Conversation

sbrugman
Copy link
Contributor

Enable PDF (and other supported formats) savefig in explainer by removing hardcoded extension

import torch
W = torch.rand(d,n_neurons)
b = torch.rand(n_neurons,1)
X = torch.rand(n,d)
with ts.explain(savefig="my_inspection.pdf"):
    Y = W @ X.T + b

Enable PDF (and other supported formats) savefig in explainer by removing hardcoded extension

```
import torch
W = torch.rand(d,n_neurons)
b = torch.rand(n_neurons,1)
X = torch.rand(n,d)
with ts.explain(savefig="my_inspection.pdf"):
    Y = W @ X.T + b
```
@parrt
Copy link
Owner

parrt commented Sep 20, 2021

Hi. I can't remember why but something prevented me from allowing non-svg. Hmm...let me look.

@parrt parrt added the enhancement New feature or request label Sep 20, 2021
@parrt
Copy link
Owner

parrt commented Sep 20, 2021

ok, looks good. We only save with plt.savefig() in one spot, PyVizView.savefig(), so should be safe to allow any extensions. thanks!

@parrt parrt merged commit 6b29954 into parrt:master Sep 20, 2021
@sbrugman sbrugman deleted the patch-1 branch September 20, 2021 21:40
@parrt
Copy link
Owner

parrt commented Sep 20, 2021

Confirmed that this works with pdf now:

import torch
import tsensor

n = 100
d = 10
n_neurons = 100
W = torch.rand(d,n_neurons)
b = torch.rand(n_neurons,1)
X = torch.rand(n,d)
with tsensor.explain(savefig="my_inspection.pdf"):
    Y = W @ X.T + b

@parrt parrt added this to the 0.1.3 milestone Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants