Thank you very much for your answers. After adding nn.Flatten(), I encountered this problem. Is my format wrong or Pytorch version?
            nn.MaxPool2d(kernel_size=2, stride=2, padding=0),
            # 128 x 4 x 4
            nn.Flatten().F,
            nn.Linear(2048, 512),
            nn.ReLU(True),