Error when running Pytorch code

1. Run Pytorch tutorial code error: BrokenPipeError: [Errno 32] Broken pipe

The problem is caused by the multi-threading problem under windows, which is related to the DataLoader class 

solution:

    Modify the num_workers parameter when calling the torch.utils.data.DataLoader() function.

   This parameter refers to the number of threads that are enabled when loading the data set. As of 11:15:52 on May 9, 2018, if the official has not resolved the bug, you can modify the num_works parameter to  to enable only one main process to load the data set, avoiding the use of multiple threads in windows.

2.TypeError: new() received an invalid combination of arguments-got(float, int)

 In fact, there is no problem with the code being defined in python2.7. The problem is that the existing python3 environment has different rules for division from python2.

512/2, The result in python3 is 256.0, but in python2, 256these differences between python2 and 3.

Solution:

       To /replace //the latter operation can be guaranteed to be an int.

Guess you like

Origin blog.csdn.net/sinat_39307513/article/details/97904582