what does norm1_adapt(X) do?

in the lab it is said that this code learns means and variance.

but why does it have to learn. Isn’t there already normalization formula?

Hello @Md_Emon,

Welcome to the community!

I assume you were asking about the optional lab “C2_W1_Lab02_CoffeeRoasting_TF”. Please also share it next time

To normalize, we need two things:

- the normalization formula, as you said;
- the constants needed by the formula, such as the mean and the variance.

As the code says:

```
norm_l.adapt(X) # learns mean, variance
```

`norm_l.adapt(X)`

gives us the constants, not the formula.

Cheers,

Raymond

thanks a lot! Understood

one more question… I’ve seen in some places where norm_1.adapt() function is used for one dataset and he mean and the standard deviation found is used for another dataset. Why is it done like that?

When we use a set of normalization constants (mean and standard deviation) on a training set to train a model, if we use that model to make prediction on a new set of data, we need to normalize that set of data with the same normalization constants. In this way, we treat the training data and the new set of data “equally”. We need to treat them equally because we are using them on the same model.