寫在前面:本人使用的是VS Code編譯器,解決的是在VS Code中出現的問題
創作不易,人走留贊!感謝!
問題一:C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\torchvision\datasets\mnist.py:498: UserWarning: The given NumPy array is
not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at …\torch\csrc\utils\tensor_numpy.cpp:180.)
return torch.from_numpy(parsed.astype(m[2],copy=False)).view(*s)
問題分析:
資料集處理程序中,無法copy資料集,從而使資料集加載器失效
解決方法:
1.找到C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\torchvision\datasets\mnist.py檔案,在read_sn3_pascalvincent_tensor 函式中找到 return torch.from_numpy(parsed.astype(m[2],copy=False)).view(*s)回傳值,將,copy=False進行洗掉保存即可
問題二:
qt.qpa.plugin: Could not find the Qt platform plugin “windows” in “”
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
問題分析:
這是環境變數問題
解決方法:
在系統環境變數中添加變數名為:QT_QPA_PLATFORM_PLUGIN_PATH
路徑為C:\Users\AppData\Local\Programs\Python\Python38\Lib\site-packages\PyQt5\Qt5\plugins
問題三:
問題解決后仍然無法顯示結果
問題分析:
代碼有問題
解決方法:
筆者在這里檢查到在Animator類中,add函式不全,如果按原視頻中的方法寫,不可行
筆者嘗試用animator = d2l.Animator代替animator = Animator,結果顯示可行,但是不會顯示圖片,終端顯示
<Figure size 700x500 with 1 Axes>
想要顯示結果圖,需要在
train_ch3(net,train_iter,test_iter,loss,num_epochs,updater)
函式中添加d2l.plt.show(),將會顯示最終結果,
這里無法顯示動圖,筆者嘗試在回圈中添加此函式,仍無法顯示動圖,并且只顯示第一輪訓練的結果,另外,如果顯示的視窗不關掉,訓練將會被中止,筆者水平有限,無法解決動圖問題
參考文獻:
https://blog.csdn.net/weixin_42116703/article/details/121236256
https://blog.csdn.net/bkdly9/article/details/120634060
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/400436.html
標籤:AI
下一篇:資料的資料表示和可視化
