網站首頁 編程語言 正文
RuntimeError: scatter(): Expected dtype int64 for index
1.報錯原因:
scatter要求數據是int64類型,而我在定義tensor時寫的是torch.Tensor(x),應該寫成torch.LongTensor(x),指定為int64類型。
2.解決方法
找到原數據的定義方式,改!
一般在dtype=np.int64;dtype=np.float32中
(多數定義函數都有dtype屬性)
最好int和float的位數要一致
import numpy as np
a = np.random.randint(100, size=(10**6), dtype="int64")
print(a)
print(type(a[0]))
原文鏈接:https://blog.csdn.net/weixin_45928096/article/details/122387959
相關推薦
- 2022-09-19 Redis緩存穿透/擊穿工具類的封裝_Redis
- 2022-04-22 uniapp小程序報錯 TypeError: Cannot read property ‘call‘
- 2024-01-07 Plugin ‘org.springframework.boot:spring-boot-maven
- 2023-03-17 學習win32com操作word之Range精講_python
- 2022-12-24 C++中STL容器的主要使用及含義說明_C 語言
- 2023-07-18 讀取Springboot的jar包中的文件資源方式
- 2022-10-04 go常用指令之go?mod詳解_Golang
- 2022-04-21 R語言數據可視化繪圖Slope?chart坡度圖畫法_R語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支