CogDL icon indicating copy to clipboard operation
CogDL copied to clipboard

Could Cogdl implement graph regression task?

Open huang429 opened this issue 3 years ago • 2 comments

I used MLP as the regression layer,but got an error that ValueError: Expected 2 or more dimensions (got 1) Is that couldn't implement graph regression task,please?

huang429 avatar Apr 17 '22 11:04 huang429

Hi @huang429, Thanks for your interest in cogdl. Could you please report your running command or script?

cenyk1230 avatar Apr 26 '22 11:04 cenyk1230

@cenyk1230感谢您的回复。 1.以下是我的MLP回归预测代码: `import torch.nn as nn import torch.nn.functional as F

class MLPregression(nn.Module): def init(self, in_features, out_features, hidden_size=16): super(MLPregression, self).init() self.in_features = in_features self.out_features = out_features self.hidden_size = hidden_size self.criterion = nn.MSELoss() # 第一个隐含层 self.hidden1 = nn.Linear(out_features, hidden_size, bias=True) # 第三个隐含层 self.hidden2 = nn.Linear(hidden_size, hidden_size) # 回归预测层 self.predict = nn.Linear(hidden_size, 1)

# 定义网络前向传播路径
def forward(self, x):
    x = F.relu(self.hidden1(x))
    x = F.relu(self.hidden2(x))
    output = self.predict(x)
    # 输出一个一维向量
    return output[:, 0]`

2.我想要将图分类预测(如GIN模型)转化为图回归预测,在GIN最后一层加了MLPRegression。 然后使用_experiment(dataset=mutag, model=“gin”, dw="graph_classification_dw", mw="graph_classification_mw")_,得到了这样的错误:ValueError: Expected 2 or more dimensions (got 1)

huang429 avatar Apr 27 '22 07:04 huang429