Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SAM + torch/numpy casting issue #160

Open
patfl84 opened this issue Mar 7, 2024 · 1 comment
Open

[BUG] SAM + torch/numpy casting issue #160

patfl84 opened this issue Mar 7, 2024 · 1 comment

Comments

@patfl84
Copy link

patfl84 commented Mar 7, 2024

Hi, there is an bug in the SAM code, line 227: https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/cdt/causality/graph/SAM.py#L227

    skeleton = th.from_numpy(skeleton.astype('float32'))
AttributeError: 'Tensor' object has no attribute 'astype'

However, skeleton is already casted to a torch.Tensor in line 510, before it goes to line 227: https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/cdt/causality/graph/SAM.py#L510

if graph is not None:
            skeleton = th.Tensor(nx.adjacency_matrix(graph,
                                                     nodelist=list(data.columns)).todense())
@patfl84 patfl84 changed the title [BUG] Function or algorithm name + Bug summary [BUG] SAM + torch/numpy casting issue Mar 7, 2024
@tooomura
Copy link

Hi, I am also facing the same issue.
I am using the Docker image [divkal/pytorch:22.03], but I encounter the same error.
The same issue occurs with another image [divkal/cdt-py3.7:latest].

When running SAM, I get an error when specifying the argument graph in predict as shown below:

import networkxs as nx
from cdt.causality.graph import SAM
from cdt.data import load_dataset

data, graph = load_dataset("sachs")
obj = SAM()
output = obj.predict(data, nx.Graph(graph)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants