# Unit integral condition on the output layer

I want to train a neural network on some input data from a probability distribution (say a Gaussian). The loss function would normally be $$-\sum\log(f(x_i))$$, where the sum is over the whole data (or in this case a mini batch) and $$f$$ is the NN function. However I need to enforce the fact that $$\int_0^\infty f(x)dx=1$$, in order for $$f$$ to be a real probability distribution. How can I add that to the loss function? Thank you!

• The loss you mentioned is used for multi class classification. Is your problem classification or regression?
– user9947
Jun 8, 2019 at 4:19
• I am given data points generated from a function (distribution) as input, and I want to train a NN to approximate that function. I am not sure if it is classification or regression. I just want to train the network to approximate f. Jun 8, 2019 at 5:00
• But apparently the function is a probability distribution. The final output will be taken from a single node I guess?
– user9947
Jun 8, 2019 at 5:29
• Both the input and the output are one single node, yes. It can be shown mathematically that given data generated by a probability distribution, the function that generated the data is the one minimizing the loss function I wrote there. I just need to impose that normalization (otherwise the constant function equal to 1 would give the smallest loss). But I am not sure how to do that. Jun 8, 2019 at 5:54
• I assume the inputs are continuous?
– user9947
Jun 8, 2019 at 6:05