Code Monkey home page Code Monkey logo

Comments (7)

seungjun45 avatar seungjun45 commented on June 28, 2024

if edge_vmax is None:
edge_vmax = statistics.median_high(
[d for (u, v, d) in Gc.edges(data="weight", default=1)]
)
min_color = min([d for (u, v, d) in Gc.edges(data="weight", default=1)])
# color range: gray to black
if type(edge_vmax) is torch.Tensor:
edge_vmax=edge_vmax.item()
edge_vmin = 2 * min_color - edge_vmax
nx.draw(
Gc,
pos=pos_layout,
with_labels=False,
font_size=4,
labels=feat_labels,
node_color=node_colors,
vmin=0,
vmax=vmax,
cmap=cmap,
edge_color=edge_colors,
edge_cmap=plt.get_cmap("Greys"),
edge_vmin=edge_vmin,
edge_vmax=edge_vmax,
width=1.0,
node_size=50,
alpha=0.8,
)

from gnn-model-explainer.

seungjun45 avatar seungjun45 commented on June 28, 2024

utils/io_utils.py

def denoise_graph(adj, node_idx, feat=None, label=None, threshold=None, threshold_num=None, max_component=True):

if type(adj) is torch.Tensor:
    adj=adj.detach().numpy()
    
num_nodes = adj.shape[-1]
G = nx.Graph()
G.add_nodes_from(range(num_nodes))
G.nodes[node_idx]["self"] = 1

...

from gnn-model-explainer.

seungjun45 avatar seungjun45 commented on June 28, 2024
  • because gradient values in adjacency matrix are very incremental, this often occurs "empty edge" error whenever calling "log_adj_grad(...)" in explain.py, line871. So i would recommend to set its threshold from 0.0003 to 0.0000

explainer/explain.py (line 916)

if self.graph_mode:
print("GRAPH model")
G = io_utils.denoise_graph(
adj_grad,
node_idx,
feat=self.x[0],
threshold=0.0000, # threshold_num=20,
max_component=True,
)

from gnn-model-explainer.

HennyJie avatar HennyJie commented on June 28, 2024

I also met with this same error when running explanation on MUTAG:

python -W ignore explainer_main.py --bmname=MUTAG --graph-mode

ValueError: Invalid RGBA argument: tensor(1., dtype=torch.float64)

I tried the solution proposed by sengjun45 that change the threshold to 0.0000, but it does not work for me. Do you possibly have any ideas on this? @RexYing

Thanks very much in advance!

from gnn-model-explainer.

Liyiqiao avatar Liyiqiao commented on June 28, 2024

@HennyJie Do you figure out how to deal with the error:
ValueError: Invalid RGBA argument: tensor(1., dtype=torch.float64)
I also get this error, when I try to run GNNExplainer on MUTAG

from gnn-model-explainer.

awezmm avatar awezmm commented on June 28, 2024

Any update on this?

from gnn-model-explainer.

awezmm avatar awezmm commented on June 28, 2024

I was able to resolve this issue by just inserting:

if torch.is_tensor(edge_colors[0]):
    print(edge_colors)
    edge_colors = [x.cpu().detach().numpy().tolist() for x in edge_colors]
    print("changed edge color to list type")
    print(edge_colors)

right before line 330 in utils/io_utils.py. I am not sure if this a proper solution as I am only converting the tensor type elements to list type.

from gnn-model-explainer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.