keras 标准化轴参数有什么作用?

What does keras normalize axis argument does?

我是深度学习的初学者,正在研究 keras 中的 mnist 数据集。

我使用归一化作为

tf.keras.utils.normalize(x_train, axis = 1)

我不明白 axis 参数是什么意思。你能帮我解决这个问题吗?

规范化函数只是执行常规规范化以提高性能:

Normalization is a rescaling of the data from the original range so that all values are within the range of 0 and 1.

在另一个 post:

中对 axis 参数有很好的解释

What is the meaning of axis=-1 in keras.argmax?

例如:

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

此外,对于那些想要更深入的人,Keras 的作者 François Chollet 在 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() 函数 the numpy.linalg.norm() 计算范数,然后对输入数据进行归一化。因此,给定的 axis 参数被传递给 norm() 函数以计算沿给定轴的范数。