Input and output dimensions in PyTorch

I have a table with 100 rows and 11 columns, first 10 columns represent the explanatory variables (X1 to X10) and the last column represents the response variable (Y), should my input data be 100 by 10 matrix and output data be 100 by 1 column vector? does the feedforward operation in PyTorch go by xW+b rather than Wx+b?

Example:

X = torch.Tensor(matrix(100, 10))
Y = torch.Tensor(vector(100, 1))

class NN(nn.Module):
    def __init__(self, input_dim = 10, output_dim=1):
        super(NN, self).__init__()
        self.lin1 = nn.Linear(input_dim, 5)
        self.lin2 = nn.Linear(5, output_dim)

    def forward(self, x):
        x = self.lin1(x)
        x = F.sigmoid(x)
        x = self.lin2(x)
        return x

Sorry for the primitive question.

According to my understanding, you do not have to care about the questions like Wx + b or xW + b in Pytorch.

When you have 100 * 10 input, it means you have the input data with batch size 100 and dimmension number 10. After the processing, the output of the neural network will be batch_size * output_dim, which is 100 * 1. So your current way of writing this is right.

1 Like

Thank you very much for the answer.