Role of activation function in calculating the cost function for artificial neural networks
-A cost function is a measure of error between what value your model predicts and what the value actually is. For example, say we wish to predict the value  yi  for data point  xi . Let  fθ(xi)  represent the prediction or output of some arbitrary model for the point  xi  with parameters  θ  . One of many cost functions could be
∑ni=1(yi−fθ(xi))2
this function is known as the L2 loss. Training the hypothetical model we stated above would be the process of finding the  θ  that minimizes this sum.
-An activation function transforms the shape/representation of the data going into it. A simple example could be  max(0,xi) , a function which outputs 0 if the input  xi  is negative or  xi  if the input  xi  is positive. This function is known as the “ReLU” or “Rectified Linear Unit” activation function. The choice of which function(s) are best for a specific problem using a particular neural architecture is still under a lot of discussion. However, these representations are essential for making high-dimensional data linearly separable, which is one of the many uses of a neural network.
I hope this gave a decent idea of what these things are. If you wish to learn more, I suggest you go through Andrew Ng’s machine learning course on Coursera. It provides a wonderful introductory look into the field.
I have some difficulty with understanding the role of activation functions and cost functions. Lets take a look at a simple example. Lets say I am building a neural network (artificial neural network). I have 5 „x“ variables and one „y“ variable. 
If I do usual feature scaling and then apply, for example, Relu activation function in hidden layer, then this activation function does the transformation and as a result we get our predicted output value (y hat) between 0 and lets say M. Then the next step is to calculate the cost function. 
In calculating the cost function, however, we need to compare the output value (y hat) with the actual value (y).
The question is how we can compare transformed output value (y hat) which is lets say between 0 and M with the untransformed actual value (y) (which can be any number as it is not been subjected to the Relu activation function) to calculate the cost function? There can be a large mismatch as one variable has been exposed to transformation and the other has not been.
Thank you for any help.