graph4ai/graph4nlp

Summarization : AttributeError: 'Graph2Seq' object has no attribute 'graph_topology'

infosel-it opened this issue ยท 3 comments

๐Ÿ› Bug

Hi

Summarization task is executed with CNN data set. For training and testing took only 100 stories. After executing the following error occurred.

AttributeError: 'Graph2Seq' object has no attribute 'graph_topology'

The error is occurred during the translate in main.py of summarization.

batch_graph = self.model.g2s.graph_topology(data["graph_data"])

But while executing inference_advance the same error is not occurred.

To Reproduce

Steps to reproduce the behavior:

  1. Take the CNN data set for 100 stories with train, and 10 records for testing and validation each.
  2. Execute the code like below with 10 epochs

python -X utf8 main.py -g2s_config config/gcn_bifuse.yaml -task_config config/cnn.yaml

  1. After executing the code the error occurred like 'Graph2Seq' object has no attribute 'graph_topology'

Traceback (most recent call last):
File "main.py", line 492, in
main(g2s_template)
File "main.py", line 468, in main
test_scores = runner.test()
File "main.py", line 393, in test
scores = self.translate(self.test_dataloader)
File "main.py", line 336, in translate
batch_graph = self.model.g2s.graph_topology(data["graph_data"])
File "C:\Users***.conda\envs\graph4nlp\lib\site-packages\torch-1.11.0-py3.8-win-amd64.egg\torch\nn\modules\module.py", line 1185, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Graph2Seq' object has no attribute 'graph_topology'

Expected behavior

In graph2seq.py file the graph_topology is initialized with condition but in the translate method of main.py it is directly accessed.
Is there any other way to get the batchgraph in translate method or how to initialize the graph_topology.

graph2seq.py , Line no 230 to 231.

if hasattr(self, "graph_topology") and hasattr(self.graph_topology, "dynamic_topology"):
batch_graph = self.graph_topology.dynamic_topology(batch_graph)

Environment

  • Graph4NLP Version (e.g., 0.4.1):
  • Backend Library & Version (e.g., PyTorch 1.6.0):
  • OS (e.g., Windows):
  • How you installed Graph4NLP (Conda, source):
  • Build command you used (if compiling from source):
  • Python version: 3.8.12
  • CUDA/cuDNN version (if applicable):
  • GPU models and configuration (e.g. 2080Ti):
  • Any other relevant information:

Additional context

I have executed for the readdit data set with few samples. It is not able to inference after training and testing,

https://www.tensorflow.org/datasets/catalog/reddit

Hi @infosel-it , you can the change "graph_topology" in line 336 to "graph_initializer". We will fix this bug in next version. "graph_topology" is used for dynamic graph construction and here we use static graph construction for summarization task.

Hi @infosel-it , thanks for reporting the issue! Close this issue for now. Please feel free to reopen it if the suggested fix does not resolve your issue. As mentioned, we will release a new version soon which will fix this issue.