I think I figured it out, by changing the input size of my linear layer to be large enough. I don’t know if this is the best approach though. Here’s my model code:

    def __init__(self, input_size, output_size, hidden_dim, n_layers):
        super(Net, self).__init__()
        self.input_size  = input_size
        self.output_size = output_size
        self.hidden_dim  = hidden_dim
        self.n_layers    = n_layers

        self.rnn = torch.nn.RNN(self.input_size, self.hidden_dim, self.n_layers, batch_first=True)
        # 64 is the size of my middle (2nd) dimension of X
        self.fc  = torch.nn.Linear(64 * hidden_dim, self.output_size)

    def forward(self, X):
        batch_size  = X.size(0) # 4
        hidden      = self.init_hidden(batch_size)
        out, hidden = self.rnn(X, hidden)
        out = out.contiguous().view(batch_size, -1)
        out = self.fc(out)
        return out, hidden

    def init_hidden(self, batch_size):
        return torch.zeros(self.n_layers, batch_size, self.hidden_dim)```