I am a beginner in deep learning and I am working upon the mnist dataset in keras.
I used normalization as
tf.keras.utils.normalize(x_train, axis = 1)
I don't understand what does the axis argument means. Can you help me out with this?
The normalize function just performs a regular normalization to improve performance:
Normalization is a rescaling of the data from the original range so that all values are within the range of 0 and 1.
There is a nice explanation of the axis argument in another post:
What is the meaning of axis=-1 in keras.argmax?
For example:
Your data has some shape (19,19,5,80). This means:
- Axis = 0 - 19 elements
- Axis = 1 - 19 elements
- Axis = 2 - 5 elements
- Axis = 3 - 80 elements
Also, for those who want to go deeper, there is an explanation from François Chollet - Keras’ author- on GitHub:
- For Dense layer, all RNN layers and most other types of layers, the default of axis=-1 is what you should use,
- For Convolution2D layers with dim_ordering=“th” (the default), use axis=1,
- For Convolution2D layers with dim_ordering=“tf”, use axis=-1 (i.e. the default).
https://github.com/fchollet/keras/issues/1921
keras.utils.normalize()
function calls the numpy.linalg.norm()
to compute the norm and then normalize the input data. The given axis
argument is therefore passed to norm()
function to compute the norm along the given axis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With