PyTorch Tutorial Error Training a Classifier

末鹿安然 提交于 2019-12-02 09:45:01

Check out the documentation for multiprocessing: programming guidelines for windows. You should wrap all operations in functions and then call them inside an if __name__ == '__main__' clause:

# required imports

def load_datasets(...):
    # Code to load the datasets with multiple workers

def train(...):
    # Code to train the model

if __name__ == '__main__':
    load_datasets()
    train()

In short, the the idea here is to wrap the example code inside an if __name__ == '__main__' statement.

Because of different implementation of multiprocessing in Windows, you need to wrap your main code with this block:

if __name__ == '__main__':

For more info, you can check the official PyTorch Windows notes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!