Pytorch中的支持向量回归

时间:2019-11-25 05:37:35

标签: non-linear-regression

我想通过提供一个图像作为输入来预测CNN模型的连续值作为输出: 下面是代码

class MultiLabelNN(nn.Module):
    def __init__(self):
        super(MultiLabelNN, self).__init__()
        self.conv1 = nn.Conv2d(3,64, 5)
        self.pool = nn.MaxPool2d(2,2)
        self.conv2 = nn.Conv2d(64, 128, 5)        
        self.conv3 = nn.Conv2d(128, 256, 5)
        self.conv4 = nn.Conv2d(256,320,5)
        self.fc1 = nn.Linear(250880,2048)
        self.fc2 = nn.Linear(2048, 1024)
        self.fc3 = nn.Linear(1024, 512)        
        self.fc4 = nn.Linear(512, 6)
    def forward(self, x):
        x = self.conv1(x)
        x = nn.ReLU(x)    
        x = self.pool(x)   
        x = self.conv2(x)
        x = nn.ReLU(x)
        x = self.pool(x)
        x = self.conv3(x)
        x = nn.ReLU(x)
        x = self.pool(x) 
        x = self.conv4(x)
        x = nn.ReLU(x)
        x = self.pool(x)        
        x = x.view(-1, 250880)
        x = self.fc1(x)        
        x = self.fc2(x)       
        x = self.fc3(x)
        x = self.fc4(x)
        return x

我想在我的最后一个完全连接的层中支持向量回归,而不是线性回归(self.fc4 = nn.Linear(512,6)).....

我的问题是,有什么选择吗?

like self.fc4 = nn.SVR(512,6)

或我听说过的任何其他有关skorch(https://github.com/skorch-dev/skorch

但是我无法使用它。请帮我。预先感谢。

0 个答案:

没有答案