TypeError: only integer scalar arrays can be converted to a scalar index
TypeError: only integer scalar arrays can be converted to a scalar index
- 在使用
np.random.choice()
時,將返回的List
作為Data[]
的索引物件 - 程式出現
TypeError: only integer scalar arrays can be converted to a scalar index
的錯誤
原始語句
sample_index = np.random.choice(num_train, batch_size, replace = True)
X_batch = X[sample_index, :]
y_batch = y[sample_index]
TypeError: only integer scalar arrays can be converted to a scalar index
解決方法
- 將
List
轉換為numpy
陣列,即:np.array(data)[List]
sample_index = np.random.choice(num_train, batch_size, replace = True)
X_batch = np.array(X)[sample_index, :]
y_batch = np.array(y)[sample_index]
相關文章
- F. Scalar Queries
- 4.2.11. Scalar Subqueries
- [記錄]RuntimeWarning: overflow encountered in scalar subtract
- .NET9 - Swagger平替Scalar詳解(四)Swagger
- 張量(Tensor)、標量(scalar)、向量(vector)、矩陣(matrix)矩陣
- OpenCV學習筆記(3)——Scalar資料型別理解OpenCV筆記資料型別
- Only AI Flow Can Do!AI
- TypeError: can‘t concat str to bytesError
- Oracle 20c 新特性:SQL 巨集支援(SQL Macro)Scalar 和 Table 模式OracleSQLMac模式
- Oracle vs PostgreSQL Develop(31) - Index Only ScanOracleSQLdevIndex
- pytorch 踩坑,TypeError: expected seqence object with len>_0 or a single integer_typeerror: expected sequence object with len __ 0PyTorchErrorObject
- 標量碼與向量碼(Scalar code & Vector code)及一些後續知識
- mac提交svn提示CHECKOUT can only be performed on a version resourceMacORM
- 14.Java-Arrays(類)、基本型別包裝類、Integer(類)Java型別
- TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tErrorObject
- 關於Warning: setState(...): Can only update a mounted or mounting component. This
- "Only fullscreen opaque activities can request orientation "問題再分析Opaque
- "ScrollView can host only one direct child"問題解決View
- Pycharm:設定完Anaconda後報錯TypeError: an integer is required (got type bytes)PyCharmErrorUIGo
- python用pyinstaller生成exe時報錯 TypeError: an integer is required (got type bytes)PythonErrorUIGo
- Android8.0適配-Only fullscreen opaque activities can request orientationAndroidOpaque
- 育碧公佈雲原生技術Ubisoft Scalar 創新突破改變遊戲開發和體驗方式遊戲開發
- python報錯:TypeError: slice indices must be integers or None or have an __index__ methodPythonErrorNoneIndex
- Can GoldenGate Replicate An Oracle Table That Contains Only CLOB Column(s)? (Doc ID 971833.1)GoOracleAI
- GCC編譯遇到“a label can only be part of a statement and a declaration is not a statement”問題GC編譯
- @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty
- 005-blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]BloCORBIndexdeleteAPI
- 【React】Invalid hook call. Hooks can only be called inside of the body of a function component.ReactHookIDEFunction
- ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAError
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- ld: -pie can only be used when targeting iOS 4.2 or later clang: error: linker command failed with eiOSErrorAI
- 【報錯】elasticsearch 報錯blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]ElasticsearchBloCORBIndexdeleteAPI
- 使用monaco編輯器 報錯Can only have one anonymous define call per script file
- Unknown initial character set index ‘255‘ received from server. Initial client character set can beIndexServerclient
- Arrays
- Arrays Basics
- 六,Arrays
- Python:Python3錯誤提示TypeError: slice indices must be integers or None or have an __index__ method解決辦法PythonErrorNoneIndex