更新时间:2023-12-02 15:05:10
是的.只需将您的输入形状更改为 shape=(n_channels, None, None).其中 n_channels 是输入图像中的通道数.
Yes. Just change your input shape to shape=(n_channels, None, None). Where n_channels is the number of channels in your input image.
我使用的是 Theano 后端,所以如果您使用的是 tensorflow,您可能需要将其更改为 (None,None,n_channels)
I'm using Theano backend though, so if you are using tensorflow you might have to change it to (None,None,n_channels)
你应该使用:
input_shape=(1, None, None)
input_shape=(1, None, None)
形状中的无"表示可变尺寸.请注意,并非所有图层将适用于此类可变尺寸,因为某些层需要形状信息(例如 Flatten).https://github.com/fchollet/keras/issues/1920
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,您的输入层将是:
For example, using keras's functional API your input layer would be:
对于 RGB 数据集
inp = Input(shape=(3,None,None))
对于灰色数据集
inp = Input(shape=(1,None,None))