THUDM / CogDL

CogDL: A Comprehensive Library for Graph Deep Learning (WWW 2023)

Home Page:https://cogdl.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could Cogdl implement graph regression task?

huang429 opened this issue · 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?

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

@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)