Thanks to Kristoffer and Adrien! Both methods work!
My problem was unrelated to Flux, but I also found that Flux.batch
provides the same functionality… almost. In fact, the above suggestions seem to be more general than Flux.batch
:
julia> a = [rand([0,1,2,3],3) for i in 1:4]
4-element Array{Array{Int64,1},1}:
[2, 0, 2]
[2, 0, 3]
[1, 0, 0]
[1, 1, 0]
julia> hcat(a...)
3×4 Array{Int64,2}:
2 2 1 1
0 0 0 1
2 3 0 0
julia> using Flux
julia> Flux.batch(a)
3×4 Array{Int64,2}:
2 2 1 1
0 0 0 1
2 3 0 0
julia> b = [rand([0,1,2,3],1) for i in 1:4]
4-element Array{Array{Int64,1},1}:
[3]
[0]
[3]
[3]
julia> hcat(b...)
1×4 Array{Int64,2}:
3 0 3 3
julia> Flux.batch(b)
1×4 Array{Int64,2}:
3 0 3 3
julia> c = rand([0,1,2,3],4)
4-element Array{Int64,1}:
3
2
2
1
julia> hcat(c...)
1×4 Array{Int64,2}:
3 2 2 1
julia> Flux.batch(c)
4-element Array{Int64,1}:
3
2
2
1
My “problem” arouse out of calling a function, say, f(x,y)
, which returns [v,w]
where v
and w
are scalars. Then, with X
a vector, f.(X,y)
returns a vector of two element vectors of type [ [v1,w1], [v2,w2],...]
where I wanted to plot V=[v1,v2,...]
as a function of X
…
Anyway, thanks!