# How to find multi-layer perceptron weights?

I want to use a multi-layer perceptron to design the following function : The architecture I want to use is the following one : What would be $w_i$ weights ? Is there any guide to find them ?

I tried the following, guessing with $\forall i,w_i=1$.

\begin{array}{|c|c|c|c|c|c|c|c|c|} \hline &w_1&w_2&w_3&w_4&w_5&w_6&w_7&y\\ &1&1&1&1&1&1&1&=\\ \hline -1&-1&-1&1&1&0&0&1&1\\ -2&-2&-2&1&1&1&1&1&0\\ -3&-3&-3&1&1&-2&-2&1&-1?\\ \hline \end{array}

As it is it seems everything goes well from there but that was only a guess ...

Why in the plotted function do I have $\sum_iw_ix_i$ ? I don't understant the $x_i$. Don't I have only one $x$ as input ?

## 2 Answers

The whole point of the Perceptron model is to find the optimal set of weights with respect to your data. You initialize them at some small random number, then with each iteration the Perceptron adjusts the weights in search of a better solution.

How to actually get the weights out of the model depends on your implementation. If you are running this model in Python / R, they should be saved in a matrix; have a look at the code.

• :/ The whole pedagogical point is to find them by hand – Revolucion for Monica Dec 20 '17 at 20:49

What you are missing is the data with ground truth and loss function, i.e., when we change the parameters, how can we measure goodness of the model.

For example, you may define 0-1 loss as the classification accuracy, suppose you have 100 data points, you can try to change the parameters and see in what setting the performance is the best.

So you are monitoring $$\sum_i L(y_i- f(x_i))$$, where $$x_i$$ is the input, and $$y_i$$ is the prediction target. $$w_i$$ will be used when calculate $$f(x_i)$$.