完全按照老師的代碼敲,出現AttributeError: 'Net' object has no attribute 'conv1'
試了改過各種變量名,一直有這個報錯,有人知道為什么嗎?
Traceback (most recent call last):
? File "E:/PythonProject/venv/Study1/2_1_test.py", line 60, in <module>
? ? out = net(input_data)
? File "E:\WorkTools\Anaconda\envs\renzhe\lib\site-packages\torch\nn\modules\module.py", line 532, in __call__
? ? result = self.forward(*input, **kwargs)
? File "E:/PythonProject/venv/Study1/2_1_test.py", line 29, in forward
? ? x = self.conv1(x)
? File "E:\WorkTools\Anaconda\envs\renzhe\lib\site-packages\torch\nn\modules\module.py", line 576, in __getattr__
? ? type(self).__name__, name))
AttributeError: 'Net' object has no attribute 'conv1'
Process finished with exit code 1
2023-08-11
檢查是否把“ def __init__(self)”? 寫成? ”def __int__(self)”了
int --> init
2020-12-21
Net 的? init方法應該是敲錯了?