snap-stanford / deepsnap

Python library assists deep learning on graphs
https://snap.stanford.edu/deepsnap/
MIT License
546 stars 57 forks source link

None type error #3

Closed robertanto closed 4 years ago

robertanto commented 4 years ago

In the constructor of the HeteroSAGE class, even if self.in_channels_self has been initialized to in_channels_neigh in case of None input, self.lin_self = nn.Linear(in_channels_self, out_channels) does not use the object parameter.

Therefore, the code returns the following error: TypeError new(): argument 'size' must be tuple of ints, but found element of type NoneType at pos 2

class HeteroSAGEConv(pyg_nn.MessagePassing):
    r"""The heterogeneous compitable GraphSAGE operator is derived from the `"Inductive Representation
    Learning on Large Graphs" <https://arxiv.org/abs/1706.02216>`_, `"Modeling polypharmacy side
    effects with graph convolutional networks" <https://arxiv.org/abs/1802.00543>`_ and `"Modeling
    Relational Data with Graph Convolutional Networks" <https://arxiv.org/abs/1703.06103>`_ papers.
    Args:
        in_channels_neigh (int): The input dimension of the end node type.
        out_channels (int): The dimension of the output.
        in_channels_self (int): The input dimension of the start node type.
            Default is `None` where the `in_channels_self` is equal to `in_channels_neigh`.
    """
    def __init__(self, in_channels_neigh, out_channels, in_channels_self=None):
        super(HeteroSAGEConv, self).__init__(aggr='add')
        self.in_channels_neigh = in_channels_neigh
        if in_channels_self is None:
            self.in_channels_self = in_channels_neigh
        else:
            self.in_channels_self = in_channels_self
        self.out_channels = out_channels
        self.lin_neigh = nn.Linear(in_channels_neigh, out_channels)
        self.lin_self = nn.Linear(in_channels_self, out_channels)
        self.lin_update = nn.Linear(out_channels * 2, out_channels)
zechengz commented 4 years ago

Thanks. I have fixed the bug and pushed it to the GitHub, and you can reinstall the fixed package by git clone the repo with a local installation. We might push the changes to the PyPI later :)

robertanto commented 4 years ago

It seems that you have introduced a bug in the __repr__ function.

A right way to resolve may be:

class HeteroSAGEConv(pyg_nn.MessagePassing):
    r"""The heterogeneous compitable GraphSAGE operator is derived from the `"Inductive Representation
    Learning on Large Graphs" <https://arxiv.org/abs/1706.02216>`_, `"Modeling polypharmacy side
    effects with graph convolutional networks" <https://arxiv.org/abs/1802.00543>`_ and `"Modeling
    Relational Data with Graph Convolutional Networks" <https://arxiv.org/abs/1703.06103>`_ papers.
    Args:
        in_channels_neigh (int): The input dimension of the end node type.
        out_channels (int): The dimension of the output.
        in_channels_self (int): The input dimension of the start node type.
            Default is `None` where the `in_channels_self` is equal to `in_channels_neigh`.
    """
    def __init__(self, in_channels_neigh, out_channels, in_channels_self=None):
        super(HeteroSAGEConv, self).__init__(aggr='add')
        self.in_channels_neigh = in_channels_neigh
        if in_channels_self is None:
            self.in_channels_self = in_channels_neigh
        else:
            self.in_channels_self = in_channels_self
        self.out_channels = out_channels
        self.lin_neigh = nn.Linear(self.in_channels_neigh, self.out_channels)
        self.lin_self = nn.Linear(self.in_channels_self, self.out_channels)
        self.lin_update = nn.Linear(self.out_channels * 2, self.out_channels)
zechengz commented 4 years ago

Right... My second commit ignored the __repr__. I have removed the second commit and now it should work.