You always need to specify both the number of input and output features in the Linear layer constructor. It seems that the order is reversed, and you forgot to add a second argument yo self.out. Additionally hidden2 will be applied to input having n_hidden features.
Try this:
class Net(nn.Module):
            def __init__(self):
                super(Net, self).__init__()
                self.hidden = nn.Linear(X.shape[1], n_hidden)
                self.hidden2 = nn.Linear(n_hidden, n_hidden)
                self.out   = nn.Linear(n_hidden, 1)

            def forward(self, x):
                x = F.relu(self.hidden(x))
                x = F.tanh(self.hidden2(x))
                x = self.out(x)
            return x

For the target, you need to give the output of your network together with the targets to a loss function and optimize that.