1. Problem description
When loading the model in Pytorch, an error is reported:
AttributeError: Can't get attribute 'CNN' on <module '__ main __' from 'E:\…
After reading a lot of other people's sharing, they are more complicated or not suitable for my situation.
2. Solutions
Copy all the classes that define the model when you trained the model before to this py file.
In my case, the entire CNN network including the __init__ method and the forward method is as follows: