The model for the single kind of deepgcn blocks. The model architecture likes: inputlayer(nfeat)--block(nbaselayer, nhid)--...--outputlayer(nclass)--softmax(nclass) |------ nhidlayer ----| The total layer is nhidlayer*nbaselayer + 2.
| 9 | |
| 10 | |
| 11 | class GCNModel(nn.Module): |
| 12 | """ |
| 13 | The model for the single kind of deepgcn blocks. |
| 14 | |
| 15 | The model architecture likes: |
| 16 | inputlayer(nfeat)--block(nbaselayer, nhid)--...--outputlayer(nclass)--softmax(nclass) |
| 17 | |------ nhidlayer ----| |
| 18 | The total layer is nhidlayer*nbaselayer + 2. |
| 19 | All options are configurable. |
| 20 | """ |
| 21 | |
| 22 | def __init__(self, |
| 23 | nfeat, |
| 24 | nhid, |
| 25 | nclass, |
| 26 | nhidlayer, |
| 27 | dropout, |
| 28 | baseblock="mutigcn", |
| 29 | inputlayer="gcn", |
| 30 | outputlayer="gcn", |
| 31 | nbaselayer=0, |
| 32 | activation=lambda x: x, |
| 33 | withbn=True, |
| 34 | withloop=True, |
| 35 | aggrmethod="add", |
| 36 | mixmode=False): |
| 37 | """ |
| 38 | Initial function. |
| 39 | :param nfeat: the input feature dimension. |
| 40 | :param nhid: the hidden feature dimension. |
| 41 | :param nclass: the output feature dimension. |
| 42 | :param nhidlayer: the number of hidden blocks. |
| 43 | :param dropout: the dropout ratio. |
| 44 | :param baseblock: the baseblock type, can be "mutigcn", "resgcn", "densegcn" and "inceptiongcn". |
| 45 | :param inputlayer: the input layer type, can be "gcn", "dense", "none". |
| 46 | :param outputlayer: the input layer type, can be "gcn", "dense". |
| 47 | :param nbaselayer: the number of layers in one hidden block. |
| 48 | :param activation: the activation function, default is ReLu. |
| 49 | :param withbn: using batch normalization in graph convolution. |
| 50 | :param withloop: using self feature modeling in graph convolution. |
| 51 | :param aggrmethod: the aggregation function for baseblock, can be "concat" and "add". For "resgcn", the default |
| 52 | is "add", for others the default is "concat". |
| 53 | :param mixmode: enable cpu-gpu mix mode. If true, put the inputlayer to cpu. |
| 54 | """ |
| 55 | super(GCNModel, self).__init__() |
| 56 | self.mixmode = mixmode |
| 57 | self.dropout = dropout |
| 58 | |
| 59 | if baseblock == "resgcn": |
| 60 | self.BASEBLOCK = ResGCNBlock |
| 61 | elif baseblock == "densegcn": |
| 62 | self.BASEBLOCK = DenseGCNBlock |
| 63 | elif baseblock == "mutigcn": |
| 64 | self.BASEBLOCK = MultiLayerGCNBlock |
| 65 | elif baseblock == "inceptiongcn": |
| 66 | self.BASEBLOCK = InecptionGCNBlock |
| 67 | else: |
| 68 | raise NotImplementedError("Current baseblock %s is not supported." % (baseblock)) |