# How can I train a simple model to understand the relation of math addition? [Flux]

So as the title suggests, I want to get started with Flux and I can’t really understand that much from the docs, I want to train a simple model which will take 2 numbers in the input layer and output a single number (the addition of the 2 numbers), I don’t have the understanding on how to add the output,hidden,input layers to the model nor how to write a data set (I’m used to something like [firstnum,secndnum,result]) from other languages I’ve been doing ML in.

Thank you.

Did you go through the model building basics and training sections of the docs? Those questions are addressed there. Or is there something specific from there which you find unclear?

I did go through, I didn’t manage to understand 70% of the things there, it’s not straight forward or newbie friendly at all.

@orialb I didn’t understand how can I create a Dense layer which consists of 2 input values and 1 output value when Dense gets 3 values which the first 2 of them are Integers and not arrays.

How can I add a dataset which looks like
`[(1, 1, 2), (5, 5, 10), (20, 20, 40)]` where the first two values of each element is the input and the third is the target

Let me preface this by saying that I’m not a regular Flux user (or even ML practitioner). The following code will create a model which is just one dense layer with input size 2 and output size 1:

`````` model = Dense(2,1)
``````

The last optional argument for `Dense` allows you to specify the activation function (by default it is just the identity).

As for the data set, it is basically a list of tuples of the form (x,y) , so for your example it should be:

``````data = [([1, 1], 2), ([5, 5], 10), ([20, 20], 40)]
``````

I recommend
https://juliaacademy.com/p/deep-learning-with-flux-jl because it is a lot more intuitive. I am not sure if it is updated to version 0.10 but in my opinion is a lot more undestandable than official documentation.

1 Like