concept prediction in category Keras

This is an excerpt from Manning's book Probabilistic Deep Learning: With Python, Keras and TensorFlow Probability.
The weights (strength of connections between neurons) in an artificial NN need to be learned for the task at hand. For that learning step, you use training data and tune the weights to optimally fit the data. This step is called fitting. Only after the fitting step, you can use the model to do predictions on new data.
The discussed linear regression model is of course very simple and we use it mainly to explain the underlying principles which stay the same when turning to complex DL models. In real world applications, you would often not assume a linear dependency and you would also not always want to assume that the variation of the data stays constant. You will see already in the second chapter that it is very easy to set up a NN which can model non-linear relationships. In chapter 4 and 5 you will see that it is also not hard to build a probabilistic model for a regression tasks which can model data with non-linear behavior and changing variation (see Figure 1.12). To evaluate the performance of a trained regression model, you should always use a validation data set, which was not used during training. In Figure 1.12 you see the predictions of a probabilistic DL model on a new validation set which shows that the model is able to capture the non-linear behavior of the data and also the changing data variation.
Figure 1.12 Scatterplot and validation data predictions from a Bayesian probabilistic regression model. The model was fitted on some simulated data with non-linear dependency between x and y and non-constant data variation. The solid line indicates the positions of the mean values of all predicted distributions. The upper and lower dashed lines indicate an interval in which 95% of all values are expected by the model.
![]()
But what happens if we use the model to predict the outcome on x-values outside the range of the training data? You can get a first glimpse when looking at the Figure 1.12 where we only have data between 0 and 20, but show the predictions in a wider range between -5 and 25. It seems that the model is especially certain about its predictions in the ranges where it never has seen data (see figure 1.12). That is strange and not a desirable property of a model! The reason for that shortcoming of the model is, that it only captures the variation of the data, but it does not capture the uncertainty about the fitted parameters. In statistics, there are different approaches known to capture this uncertainty; the Bayesian approach is among these approaches. When working with DL models, the Bayesian approach is the most feasible and appropriate approach and you will learn about it in the last two chapters of our book.