The model m as defined takes a one-dimensional vector as input and outputs a one-dimensional vector:
julia> m([1.2])
1-element Vector{Float64}:
-0.7267242113929453
Now,
- why does
m(input2)not work?
You are passing a vector of 401 dimensions instead of one. - why does
m.(input2)ormap(m, input2)not work?
This calls the model on each element, i.e., a scalar, ofinput. Yet, a Flux model requires a vector as input. The following will work:
Passing multiple inputs in this fashion is inconvenient though and the output is a nested vector of vectors. Thus, Flux allows passing a matrix of shape input dimension \times batch size to compute the outputs on a whole batch of inputs.map(x -> m([x]), input2) m.(eachrow(input2)) - why does
m(input1)work?
input1has shape(1, 401)and is therefore interpreted as a batch of 401 one-dimensional inputs. Accordingly, it does work, computes the outputs on all 401 inputs and collects them into a matrix of shape output dimension \times batch size.