# If a neural network is a function f that maps x to y, how can I formally define a neural network with multiple outputs?

Formally I can say that a simple neural network can be formally defined as where D is the size of the input vector x and L the size of the output vector y. So I can say that $$y = f(x)$$. But how do I define this for a more complex model that have multiple inputs and outputs. For instance, consider such a network:

It consists of three inputs $$x_1, x_2, x_3$$ and two outputs $$y_1, y_2$$. How do I formally describe that network?

Is $$f(x_1, x_2, x_3) = \{y_1, y_2\}$$ a formally correct way?

Or would I better say that neural network $$f$$ cosnists of several branches for every output? So that I would define a seperate function that maps its input to the output. Such that my neural network $$f$$ is defined by the following two functions: $$f_1(x_1, x_2, x_3)=y_1$$ and $$f_2(x_1, x_2, x_3)=y_2$$.

I can not find any source who defines a neural network with multiple output in such a formal way. Thanks for your help!

Edit: $$y_1 \in R$$ and $$y_1 \in R^4$$

• both ways are good. Using $f_i$ is useful for computing derivatives, errors, etc. Using just $f$, you'd better switch to vector notations, meaning that $f$ is a function $f:\mathbb R^3\to \mathbb R^2$ from a vectorial space to another. May 16 '20 at 17:52
• @Exodd thanks for your fast reply! Only for clarification because I am not a math expert: Can I write $f:R^3 \mapsto R^2$ although $y_1$ and $y_2$ have different dimensions such as $y_1 \in R$ and $y_1 \in R^4$. And also the input $x_1, x_2, x_3$ are not scalars and vectors. So, how can I connect both things: that $f$ has mutliple inputs and outputs and also state their dimensions? Thanks a lot in advance. Please post this answer as a solution so I can accept it. May 16 '20 at 19:44
• @Exodd I posted an follow-up question that you might be able to answer: math.stackexchange.com/questions/3712687/… Jun 9 '20 at 15:17

Both ways are good. Using $$f_i$$ is useful for computing derivatives, errors, etc.
Using just $$f$$, you'd better switch to vector notations, meaning that $$f$$ is a function from a vectorial space to another.
Usually, to encode the inputs and output in a machine, you always use vectors of number (for example, a picture is just a vector of pixel intensities, or a string is just a sequence of ASCII codes). In this sense, if $$x_i\in\mathbb R^{n_i}$$, then you can see the input $$(x_1,x_2,x_3)$$ as a vector in $$\mathbb R^{n_1+n_2+n_3}$$ and analogously, if $$y_i\in\mathbb R^{m_i}$$, then you can see the output $$(y_1,y_2)$$ as a vector in $$\mathbb R^{m_1+m_2}$$. In this case, $$f$$ is a function between vectorial spaces $$f:\mathbb R^{n_1+n_2+n_3}\to \mathbb R^{m_1+m_2}$$