# Should the range and initial values of weights and biases be adjusted to fit input and output data?

As a routine (in typical everyday tasks) of a data scientist, should they usually decide about weights and biases range and initial values as a function of which data they are planning to insert as an input, and which type of data they expect to get in the output? Or we usually do not deal with such fine-tuning, and let the algorithm to do it? One could answer that normalizing inputs solves the problem and no need to fit weights and biases, but I guess they depend also on expected output.

To summarize:

1. is it common to deal with weights and biases in everyday tasks or in most of the cases existing algorithms do it well?

2. what are the rules of thumb for how to decide about range and initial values of weights and biases?

is it common to deal with weights and biases in everyday tasks or in most of the cases existing algorithms do it well?

No; and it is no coincidence that you will not be able to find any reference to such a practice in any course or tutorial about neural networks. Such a practice would require a whole additional level of (business/SME) know-how in order to meaningfully apply neural networks to real-world problems, and fortunately this is not necessary.

The desired situation is for both weights & biases to remain in a relatively small* range around zero, among other reasons because this avoids the exploding & vanishing gradient problems, which is catastrophic for learning; trying to adjust for the scale of our inputs & outputs by scaling accordingly the model weights & biases is the wrong approach, and never followed.

[*How small? Well, see here and here for what a change in just the standard deviation of a zero-mean weight initialization from 1.0 and 0.1 to 0.01 can do to the model performance]

It is a well-established fact by now that neural nets work with normalized inputs, and, depending on the problem, normalized outputs as well; which answers to your objection:

One could answer that normalizing inputs solves the problem and no need to fit weights and biases, but I guess they depend also on expected output.

It depends indeed, but the solution here is to scale the output(s) as well, and not the weights.

Now, it's true that de-scaling the outputs back to their original range in order to be able to meaningfully compare them with the ground truth (and possibly compute more meaningful metrics, like the error on our true output range, and not the scaled one) is AFAIK seldom mentioned in introductory expositions; but this is indeed the correct thing to do (especially for regression problems, where metrics like MSE are scale-sensitive), instead of trying to manually intervene on the weights range. For details, see own answers in How to interpret MSE in Keras Regressor and ANN regression accuracy and loss stuck.

what are the rules of thumb for how to decide about range and initial values of weights and biases?

Range aside, the general rule, as already implied, is to initialize the biases with zeros and the weights with small random values around zero. Nevertheless, the exact details are an area of active research. Currently used initialization schemes that are already integrated into the relevant frameworks (Tensorflow, Keras, Pytorch etc) are the Glorot (or Xavier) and He initializations (for a nice overview, see Weight Initialization in Neural Networks: A Journey From the Basics to Kaiming).

Beyond these routinely-used approaches that have already reached the practitioner's workbench, and moving closer to the front of active theoretical research, the Lottery Ticket Hypothesis (finding "winning" weight initializations that require minimal training) is an ultra-hot topic lately.

• ok no prob. Please tell me, you can add to your answer as part 3 of same question. What about activation functions? same 2 questions (is it common to deal with them as a routine, and if so what are thumb rules) – Igor Oct 14 '20 at 17:31
• @Igor ReLU and its variants for almost all uses in the intermediate layers; output ones depend on the problem - sigmoid or softmax for classification problems, linear for regression ones. – desertnaut Oct 14 '20 at 17:34