且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Keras:将图像输入CNN并获取图像输出

更新时间:2023-12-02 08:45:40

嗯,这不是规则,但是您可能会使用主要是2D转换层和相关层。

Well, this is not a "rule", but probably you will be using mostly 2D conv and related layers.

通常,您将所有内容作为numpy数组提供,也许会标准化这些值。常见选项为:

You feed everything as numpy arrays, as usual, maybe normalizing the values. Common options are:


  • 介于0和1之间(除以255。)

  • 之间- 1和1(除以255。乘以2,然后减去1)

  • Caffe样式:从每个通道中减去一个特定的值,以便根据它们的通常平均值将值居中,而无需重新缩放

您的模型应以类似以下内容的开头:

Your model should start with something like:

inputTensor = Input((2048,2048,1))
output = Conv2D(filters, kernel_size, .....)(inputTensor)    

或者,在顺序模型中: model.add(Conv2D(....,input_shape =(2048,2048,1 ))

Or, in sequential models: model.add(Conv2D(...., input_shape=(2048,2048,1))

稍后,由您决定要使用的图层。

Later, it's up to you to decide which layers to use.


  • Conv2D

  • MaxPooling2D

  • Upsampling2D

您是要创建线性模型还是要划分分支,联接分支等。

Whether you're going to create a linear model or if you're going to divide branches, join branches, etc. is also your call.

Mod U-Net 样式的els对您来说应该是一个好的开始。

Models in a U-Net style should be a good start for you.

不能做的事情


  • 不要使用Flatten图层(实际上,可以,如果以后再调整输出以具有图像尺寸...但是为什么呢?)

  • 不要使用Global Pooling图层(您不要不想牺牲您的空间尺寸)