零中心归一化是什么意思?我怎么能用keras做这个?

2024-05-16 17:37:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我在MATLAB中检查了AlexNet的设计,总结如下: enter image description here

输入层使用zerocenter标准化来表示227x227x3zerocenter规范化是什么意思?我怎么能做这个keras?在

我正在查看preprocessing documentation at keras,不确定以下任何属性是否满足zerocenter规范化?文档中也给出了属性:

 - featurewise_center
 - samplewise_center
 - featurewise_std_normalization
 - samplewise_std_normalization

Tags: 文档属性documentation规范化atkerascenterstd
2条回答

MATLAB中zerocenter规范化的定义已在imageInputLayerdocumentation中指定:

  • 'zerocenter' — Subtract the average image specified by the AverageImage property. The trainNetwork function automatically computes the average image at training time.

因此,从输入图像中减去平均图像,使它们的平均值为零(这有助于在模型训练期间实现平滑和快速的优化过程)。因此,Keras中的等效选项是featurewise_center

  • featurewise_center: Boolean. Set input mean to 0 over the dataset, feature-wise.

请注意,您需要调用fit()方法来计算平均图像:

datagen = ImageDataGenerator(featurewise_center=True, ...)

datagen.fit(train_data) 

# now you can call `flow`

零中心标准化通常意味着图像标准化为平均值为0,标准偏差为1。如果您的图像是NumPy阵列,则可以轻松实现:

img = (img - img.mean()) / img.std()

samplewise_centersamplewise_std_normalization执行相同的操作,确保每个图像的平均值为0,标准偏差为1。如果您想使用数据集的mean/std,而不是samplewise mean/std,我想您应该手动执行。在

相关问题 更多 >