self.criterion = nn.CrossEntropyLoss(reduction=‘none’)
Dataset - Airbnb dataset to predict prices
Model -MLP Regressor
Model
class MLP_Regressor(nn.Module):
     def __init__(self,config):
      super(MLP_Regressor, self).__init__()
      self.fc1 = nn.Linear(config['n_inputs'], config['n_hidden'])
      self.act1 = ReLU()
      self.fc2 = nn.Linear(config['n_hidden'], config['n_hidden'])
      self.act2 = ReLU()
      self.fc3 = nn.Linear(config['n_hidden'],1)#1


     def forward(self, X):
         X = self.fc1(X)
         X = self.act1(X)
         X = self.fc2(X)
         X = self.act2(X)
         X = self.fc3(X)


     return X

training -
def _train(self, cur_epoch, dataset_name):
    self.net.train()
    self.net.training = True
    train_losses = 0.0
    clf_losses = 0.0
    metric_losses = 0.0
    d_losses = 0.0
    g_losses = 0.0
    correct = 0
    total = 0
    n_batch = len(self.train_loader)
    print(f'\n=> Training Epoch #{cur_epoch}')
    for batch_idx, (inputs, labels) in enumerate(self.train_loader):

        inputs, labels = inputs.to(
            self.device), labels.to(self.device)

        # seed_features = self.net.extract_features(inputs, seq_lens)
        features = inputs.float()

        labels = labels.type(torch.LongTensor)
        outputs = self.net.forward(features)  # Forward Propagation
        inputs = inputs.to(self.device)
            labels = labels.to(self.device)

            features = inputs
            outputs = encoder(inputs.float())
        
            labels=labels.long()
            labels=torch.argmax(labels, dim=1)
          
            #labels = labels.reshape((labels.shape[0], 1))
            loss = self.criterion(outputs, labels)