Skip to content

AttributeError: 'Graph' object has no attribute 'train_mask' #432

Description

@Song-xx

❓ Questions & Help

I am using unsup_graphsage to train on cora dataset. This error happens.

my enviroment is:

cogdl==0.6.0
macos m1
python=3.9

the error message is :

Traceback (most recent call last):
  ......
  File "/Users/xxx/python3.9/site-packages/cogdl/pipelines.py", line 204, in __call__
    model = train(self.args)
  File "/Users/xxx/python3.9/site-packages/cogdl/experiments.py", line 147, in train
    dataset_wrapper = dw_class(dataset, **data_wrapper_args)
  File "/Users/xxx/python3.9/site-packages/cogdl/wrappers/data_wrapper/node_classification/unsup_graphsage_dw.py", line 18, in __init__
    dataset, sizes=sample_size, batch_size=batch_size, mask=dataset.data.train_mask
AttributeError: 'Graph' object has no attribute 'train_mask'

The problem code lies in:

class UnsupGraphSAGEDataWrapper(DataWrapper):
    @staticmethod
    def add_args(parser):
        # fmt: off
        parser.add_argument("--batch-size", type=int, default=128)
        parser.add_argument("--sample-size", type=int, nargs='+', default=[10, 10])
        # fmt: on

    def __init__(self, dataset, batch_size: int, sample_size: list):
        super(UnsupGraphSAGEDataWrapper, self).__init__(dataset)
        self.dataset = dataset
        self.train_dataset = UnsupNeighborSamplerDataset(
            dataset, sizes=sample_size, batch_size=batch_size, mask=dataset.data.train_mask
        )
        self.val_dataset = UnsupNeighborSamplerDataset(
            dataset, sizes=sample_size, batch_size=batch_size * 2, mask=dataset.data.val_mask
        )
        self.test_dataset = UnsupNeighborSamplerDataset(
            dataset=self.dataset,
            mask=None,
            sizes=[-1],
            batch_size=batch_size * 2,
        )
        self.x = self.dataset.data.x
        self.y = self.dataset.data.y
        self.batch_size = batch_size
        self.sample_size = sample_size

I tried to find a solution but failed. Any one can help me ? thx

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions