echowve / meshGraphNets_pytorch

PyTorch implementations of Learning Mesh-based Simulation With Graph Networks
Apache License 2.0
142 stars 31 forks source link

issues in utils.utils.py and questions about edge normalization. #7

Open SangwookBaek opened 9 months ago

SangwookBaek commented 9 months ago

Hello. ThanksHello everyone, First of all, thank you for sharing such a good implementation. It seems that there is a bug in the utils.py file in the utils directory. The code is as follows:

# see https://github.com/sungyongs/dpgn/blob/master/utils.py
def decompose_graph(graph):
    # graph: torch_geometric.data.data.Data
    # TODO: make it more robust
    x, edge_index, edge_attr, global_attr = None, None, None, None
    for key in graph.keys:
        if key=="x":
            x = graph.x
        elif key=="edge_index":
            edge_index = graph.edge_index
        elif key=="edge_attr":
            edge_attr = graph.edge_attr
        elif key=="global_attr":
            global_attr = graph.global_attr
        else:
            pass
    return (x, edge_index, edge_attr, global_attr)

There seems to be a missing () in the graph.keys part, which is causing an error. Also, I have a question, not an error. I noticed that in DeepMind's repository, edge normalization is performed, but in your repository's simulator, Edge_normalization is commented out and not implemented separately. I am curious if there is a specific reason for excluding it. Once again, thank you for your efforts.

Xiaozl11 commented 6 months ago

不知道您是否结局了这个问题,我遇到了类似的地方 信息如下: root@dbd8511a62f7:/workdisk/meshGraphNets_pytorch# python3 train.py Simulator model initialized Optimizer initialized Dataset /workdisk/data_h5/train.h5 Initilized Traceback (most recent call last): File "/workdisk/meshGraphNets_pytorch/train.py", line 54, in train(simulator, train_loader, optimizer) File "/workdisk/meshGraphNets_pytorch/train.py", line 33, in train predicted_acc, target_acc = model(graph, velocity_sequence_noise) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "/workdisk/meshGraphNets_pytorch/model/simulator.py", line 54, in forward predicted = self.model(graph) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "/workdisk/meshGraphNets_pytorch/model/model.py", line 87, in forward graph= self.encoder(graph) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/workdisk/meshGraphNets_pytorch/model/model.py", line 26, in forward nodeattr, , edgeattr, = decompose_graph(graph) File "/workdisk/meshGraphNets_pytorch/utils/utils.py", line 22, in decompose_graph for key in graph.keys: TypeError: 'method' object is not iterable 我不太清楚哪里出了问题,感谢您的回答!