[英]Julia - how to define an array of images for FluxML mlp?
我希望重用此代碼:
https://github.com/FluxML/model-zoo/blob/master/vision/mnist/mlp.jl
但帶有我自己的圖像集 我想我需要定義一個對象,例如Array {Array {Gray {Normed {UInt8,8}},2},1}類型的imgs
如何初始化圖像數組以獲得以下類型的東西:
Array{Array{Gray{Normed{UInt8,8}},2},1}
我試過了,但是失敗了:
x = Array{Array{ColorTypes.Gray{FixedPointNumbers.Normed{UInt8,8}},2}}(10)
ERROR: MethodError: no method matching Array{Array{Gray{Normed{UInt8,8}},2},N} where N(::Int64)
Closest candidates are:
Array{Array{Gray{Normed{UInt8,8}},2},N} where N(::UndefInitializer, ::Int64) where T at boot.jl:416
Array{Array{Gray{Normed{UInt8,8}},2},N} where N(::UndefInitializer, ::Int64, ::Int64) where T at boot.jl:417
Array{Array{Gray{Normed{UInt8,8}},2},N} where N(::UndefInitializer, ::Int64, ::Int64, ::Int64) where T at boot.jl:418
...
Stacktrace:
[1] top-level scope at none:0
要創建一個空向量,請使用:
Array{Array{Gray{Normed{UInt8,8}},2},1}()
那么您就可以使用push!
向其添加圖像的功能。 另外,您可以編寫與:
Vector{Matrix{Gray{Normed{UInt8,8}}}}()
這比較容易閱讀。
或者,您可以編寫:
Array{Array{Gray{Normed{UInt8,8}},2},1}(undef, 10)
創建具有10個條目的未初始化向量。 然后,您可以使用常規索引設置語法對其進行初始化。 同樣,您也可以將其編寫為:
Vector{Matrix{Gray{Normed{UInt8,8}}}}(undef, 10)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.