Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could Cogdl implement graph regression task? #342

Open
huang429 opened this issue Apr 17, 2022 · 2 comments
Open

Could Cogdl implement graph regression task? #342

huang429 opened this issue Apr 17, 2022 · 2 comments

Comments

@huang429
Copy link

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?

@cenyk1230
Copy link
Member

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

@huang429
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants