I think the software version caused this error.
I changed the code as follows,this error no longer appears, but a new error has occurred.
code:
change “import torch.nn.functional as F” to  “import torch.nn as nn”
change"x = (F.max_pool2d(previous_conv, kernel_size=kernel_size, stride=stride, padding=pooling)).view(num_sample, -1)" to “x = nn.MaxPool2d(previous_conv, kernel_size, stride, pooling)”
The new error is “AttributeError: ‘MaxPool2d’ object has no attribute ‘view’”
I don’t kown why,could you heip me?