AttributeError: module 'torch.nn' has no attribute 'GELU'
时间: 2023-08-27 08:15:05 浏览: 316
开发errorjsp-手把手带你入门ssh项目
这个错误是因为在pytorch的版本升级后,`nn.GELU()`这个函数在新版本中被移除了。解决这个问题的方法是将原来的`nn.GELU()`替换为`nn.ReLU(inplace=True)`。 这样就可以避免`AttributeError: module 'torch.nn' has no attribute 'GELU'`的错误了。
引用<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [AttributeError: module ‘torch.nn‘ has no attribute ‘GELU](https://blog.csdn.net/weixin_44790486/article/details/119241892)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [解决错误AttributeError: module ‘torch.nn.parameter‘ has no attribute ‘UninitializedParameter‘的...](https://blog.csdn.net/adc_zyc/article/details/127919885)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文