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]
相關文章
- PHP中的scalarPHP
- F. Scalar Queries
- [記錄]RuntimeWarning: overflow encountered in scalar subtract
- OpenCV學習筆記(3)——Scalar資料型別理解OpenCV筆記資料型別
- 張量(Tensor)、標量(scalar)、向量(vector)、矩陣(matrix)矩陣
- PHP Fatal error: Cannot use PhpParser\Node\Scalar\String as StringPHPError
- Oracle 20c 新特性:SQL 巨集支援(SQL Macro)Scalar 和 Table 模式OracleSQLMac模式
- TypeError: can‘t concat str to bytesError
- 標量碼與向量碼(Scalar code & Vector code)及一些後續知識
- for public synonym, only sys user can compile it?Compile
- pytorch 踩坑,TypeError: expected seqence object with len>_0 or a single integer_typeerror: expected sequence object with len __ 0PyTorchErrorObject
- 14.Java-Arrays(類)、基本型別包裝類、Integer(類)Java型別
- Oracle vs PostgreSQL Develop(31) - Index Only ScanOracleSQLdevIndex
- mac提交svn提示CHECKOUT can only be performed on a version resourceMacORM
- Android @Field parameters can only be used with form encodingAndroidORMEncoding
- 錯誤處理--pure specifier can only be specified for functionsFunction
- 育碧公佈雲原生技術Ubisoft Scalar 創新突破改變遊戲開發和體驗方式遊戲開發
- TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tErrorObject
- "Only fullscreen opaque activities can request orientation "問題再分析Opaque
- Pycharm:設定完Anaconda後報錯TypeError: an integer is required (got type bytes)PyCharmErrorUIGo
- python用pyinstaller生成exe時報錯 TypeError: an integer is required (got type bytes)PythonErrorUIGo
- "ScrollView can host only one direct child"問題解決View
- Only a type can be imported. classname resolves to a package的解決ImportPackage
- Swift代理報錯Optional can only be applied to members of an @objc protocolSwiftAPPOBJProtocol
- Android8.0適配-Only fullscreen opaque activities can request orientationAndroidOpaque
- python報錯:TypeError: slice indices must be integers or None or have an __index__ methodPythonErrorNoneIndex
- 解決Android 8 0的Only fullscreen opaque activities can request orientatioAndroidOpaque
- ORA-02030: can only select from fixed tables/viewsView
- GCC編譯遇到“a label can only be part of a statement and a declaration is not a statement”問題GC編譯
- DIA-48449: Tail alert can only apply to single ADR homeAIAPP
- Arrays
- 005-blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]BloCORBIndexdeleteAPI
- oracle plsql_table of_index by binary_integer_for loop_批量賦值OracleSQLIndexOOP賦值
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- 使用monaco編輯器 報錯Can only have one anonymous define call per script file
- delphi open arrays和dynamic arrays區別
- 六,Arrays
- Arrays Basics