Reputation: 14604
I wish to re-use this code:
https://github.com/FluxML/model-zoo/blob/master/vision/mnist/mlp.jl
but with my own set of images. I think I need to define an object like imgs of type Array{Array{Gray{Normed{UInt8,8}},2},1}
How do I initialize an array of images to obtain something of the following type:
Array{Array{Gray{Normed{UInt8,8}},2},1}
I tried this, but it fails:
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
Upvotes: 0
Views: 272
Reputation: 69909
To create an empty vector use:
Array{Array{Gray{Normed{UInt8,8}},2},1}()
then you can use the push!
function to add images to it. Alternatively you could write the same as:
Vector{Matrix{Gray{Normed{UInt8,8}}}}()
which is a bit easier to read.
Alternatively you can write:
Array{Array{Gray{Normed{UInt8,8}},2},1}(undef, 10)
To create an uninitialized vector with 10 entries. Then you can use normal index setting syntax to initialize it. Again you could write it also as:
Vector{Matrix{Gray{Normed{UInt8,8}}}}(undef, 10)
Upvotes: 1