论文复现 Rank consistent ordinal regression for neural networks withapplication to age estimation

论文复现 Rank consistent ordinal regression for neural networks withapplication to age estimation_第1张图片

 

import torch
import torch.nn.functional as F
from torch import nn
from torch.autograd import Variable
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import Normalizer
from time import time

class RCORNN(torch.nn.Module):
    def __init__(self,nDim, n_hidden, nClass):
        self.nClass = nClass
        super(RCORNN, self).__init__()
        self.hidden_layer = torch.nn.Linear(nDim, n_hidden)
        self.output_layer = torch.nn.Linear(n_hidden, 1)
        self.linear_1_bias = torch.nn.Parameter(torch.ones(nClass-1).float())

    def forward(self, X):
        X = F.relu(self.hidden_layer(X))
        out = self.output_layer(X)
        logits = out + self.linear_1_bias
        probs = torch.sigmoid(

你可能感兴趣的:(Pytorch,算法)