Transition from Training to Testing from PyTorch Examples

Hi all,

I’m looking at the Learning PyTorch with Examples page (see example code below).

https://pytorch.org/tutorials/beginner/pytorch_with_examples.html#pytorch-custom-nn-modules

I’m a little confused about where to go from here in terms of testing my model now. It is unclear to me how I apply my new model/linear relationship to “forecasting” to hindcasting on my data.

I also am not sure how to extract the relevant weights for each input layer.

Any help would be appreciated. Thanks!

Callum

class TwoLayerNet(torch.nn.Module):
    def __init__(self, D_in, H, D_out):
        """
        In the constructor we instantiate two nn.Linear modules and assign them as
        member variables.
        """
        super(TwoLayerNet, self).__init__()
        self.linear1 = torch.nn.Linear(D_in, H)
        self.linear2 = torch.nn.Linear(H, D_out)

    def forward(self, x):
        """
        In the forward function we accept a Tensor of input data and we must return
        a Tensor of output data. We can use Modules defined in the constructor as
        well as arbitrary operators on Tensors.
        """
        h_relu = self.linear1(x).clamp(min=0)
        y_pred = self.linear2(h_relu)
        return y_pred