gpt4 book ai didi

machine-learning - Keras 可以处理不同尺寸的输入图像吗?

转载 作者:行者123 更新时间:2023-11-30 08:20:26 25 4
gpt4 key购买 nike

Keras 可以处理不同尺寸的输入图像吗?例如,在全卷积神经网络中,输入图像可以具有任意大小。然而,我们在用Keras创建网络时需要指定输入形状。因此,我们如何使用 Keras 来处理不同的输入尺寸而不将输入图像调整为相同的尺寸?感谢您的帮助。

最佳答案

是的。只需将输入形状更改为 shape=(n_channels, None, None) 即可。其中 n_channels 是输入图像中的 channel 数。

我使用的是 Theano 后端,所以如果您使用的是 tensorflow ,您可能需要将其更改为 (None,None,n_channels)

You should use:

input_shape=(1, None, None)

None in a shape denotes a variable dimension. Note that not all layers will work with such variable dimensions, since some layers require shape information (such as Flatten). https://github.com/fchollet/keras/issues/1920

例如,使用 keras 的函数式 API,您的输入层将是:

对于 RGB 数据集

inp = Input(shape=(3,None,None))

对于灰色数据集

inp = Input(shape=(1,None,None))

关于machine-learning - Keras 可以处理不同尺寸的输入图像吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39814777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com