# Single number and array as input in Flux model

**URL:** https://discourse.julialang.org/t/single-number-and-array-as-input-in-flux-model/54986
**Category:** Machine Learning
**Created:** [February 10, 2021, 12:04pm UTC](https://discourse.julialang.org/t/single-number-and-array-as-input-in-flux-model/54986 "2021-02-10T12:04:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![anon74562486](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anon74562486](https://discourse.julialang.org/u/anon74562486)
#### Post date: [February 10, 2021, 12:04pm UTC](https://discourse.julialang.org/t/single-number-and-array-as-input-in-flux-model/54986/1 "2021-02-10T12:04:27Z")

</div>

Suppose I have a Flux simple model like this:

```julia
model = Dense(1, 10)

```

If I try to call this model with a single number I get an error:

```julia
model(0.3) # ERROR

```

However If I do this the model works correctly:

```julia
model([0.3])

```

Do I always have to convert the number into an array?  
Is there a more elegant way to do this?

How can I call the model on an array or on a matrix? (I want to call the model on every single number of the array)  
This doesn’t works with single numbers:

```julia
my_model(x) = reshape(reshape(x, (1, length(x))) |> model, size(x))

```

Thank you and sorry for my english

---

<div class="post-metadata">

### Author: ![DeepQ](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@DeepQ](https://discourse.julialang.org/u/DeepQ)
#### Post date: [February 10, 2021, 3:50pm UTC](https://discourse.julialang.org/t/single-number-and-array-as-input-in-flux-model/54986/2 "2021-02-10T15:50:44Z")

</div>

A neural network is a combination of some matrices and vectors. So every input is an array and not a number.
