CounterfactualExplanations.jl
CounterfactualExplanations.jl copied to clipboard
Update Model Catalogue docs
When trying to import a PyTorch model as explained in the docs (https://juliatrustworthyai.github.io/CounterfactualExplanations.jl/dev/tutorials/model_catalogue/#Importing-PyTorch-models). I get the following error:
ERROR: MethodError: no method matching pytorch_model_loader(::String, ::String, ::String, ::String)
According to Patrick, the code for importing has been moved to TaijaInteroperability.jl
. This has to be updated in the docs.
Thanks @izagorac! In the meantime, you should be able to use the method as expected by first importing the package:
using CounterfactualExplanations
using TaijaInteroperability
...
I'm a bit surprised thought that the error message didn't already hint at this, since we've deprecated the method.
If it's not too much trouble, can you post a minimum working example here including information about the exact package version you're using?
Thanks!
@kmariuszk for info
Find my code and error message below. Im using CounterfactualExplanations v.0.1.31.
model_loaded = CounterfactualExplanations.Models.pytorch_model_loader(
"$(pwd())/docs/src/tutorials/miscellaneous",
"neural_network_class",
"NeuralNetwork",
"$(pwd())/docs/src/tutorials/miscellaneous/pretrained_model.pt"
)
M = CounterfactualExplanations.Models.PyTorchModel(model_loaded, counterfactual_data.likelihood)
Can you try instead:
model_loaded = TaijaInteroperability.pytorch_model_loader(...)
It gives the exact same error. I'm using TaijaInteroperability v.0.1.0
Hmm alright thanks! @kmariuszk any idea what's going on here?
Hey @izagorac, did you also activate the PythonCall
package in your environment?
To give you a better overview of what I mean: Python and R functionality are package extensions in TaijaInteroperability.jl
, which means you have to activate some weak dependencies to make them activate their appropriate functionality, so if you want to use Python functionality you have to run using TaijaInteroperability, PythonCall
and the same applies to RCall
. We did this to minimize the pain of users waiting for both PythonCall
and RCall
pre-compilation and to minimize the chance of errors caused by using both of these packages in the same environment.
Let me know if that solves the problem!
Also, @pat-alt regarding this bit:
I'm a bit surprised thought that the error message didn't already hint at this, since we've deprecated the method.
We didn't release the latest version of package and thus users can still use PyTorch functionality in the original way, i.e., using CounterfactualExplanations, PythonCall
Also, @pat-alt regarding this bit:
I'm a bit surprised thought that the error message didn't already hint at this, since we've deprecated the method.
We didn't release the latest version of package and thus users can still use PyTorch functionality in the original way, i.e.,
using CounterfactualExplanations, PythonCall
Ah yes, of course! Thanks for checking @kmariuszk
Thanks @kmariuszk and @pat-alt, it works when using PythonCall
. Before I was using PyCall
, does that mean that that package is not necessary anymore?
Thanks @kmariuszk and @pat-alt, it works when
using PythonCall
. Before I wasusing PyCall
, does that mean that that package is not necessary anymore?
Yes, we decided not to use PyCall
quite some time ago due to some bugs it was introducing. We're going to work on updating the documentation in the upcoming two weeks, so (hopefully) you won't experience such ambiguities anymore