20241022_01

from keras import Input

from keras.layers import Conv2D

from keras.layers import MaxPooling2D

from keras.layers import Dropout

from keras.models import Model

from keras.layers import concatenate

from tensorflow.keras.optimizers import Adam

from keras.layers import Conv2DTranspose

def Enhancednet(pretrained_weights=None):

input_shape = (None, None, 1)

inputs = Input(shape=input_shape, name='input_img')

conv1 = Conv2D(16, 5, activation='relu', padding='same')(inputs)

drop1 = Dropout(0.6)(conv1)

pool1 = MaxPooling2D(pool_size=(2, 2))(drop1)

conv2 = Conv2D(24, 5, activation='relu', padding='same')(pool1)

drop2 = Dropout(0.6)(conv2)

pool2 = MaxPooling2D(pool_size=(2, 2))(drop2)

conv3 = Conv2D(32, 5, activation='relu', padding='same')(pool2)

drop3 = Dropout(0.6)(conv3)

pool3 = MaxPooling2D(pool_size=(2, 2))(drop3)

conv4 = Conv2D(40, 5, activation='relu', padding='same')(pool3)

drop4 = Dropout(0.6)(conv4)

up5 = Conv2D(32, 3, activation='relu', padding='same')(

Conv2DTranspose(32, 5, activation='relu', padding="same", strides=2)(drop4))

merge5 = concatenate([drop3, up5], axis=3)

conv5 = Conv2D(32, 5, activation='relu', padding='same')(merge5)

drop5 = Dropout(0.6)(conv5)

up6 = Conv2D(24, 3, activation='relu', padding='same')(

Conv2DTranspose(24, 5, activation='relu', padding="same", strides=2)(drop5))

merge6 = concatenate([drop2, up6], axis=3)

conv6 = Conv2D(24, 5, activation='relu', padding='same')(merge6)

drop6 = Dropout(0.6)(conv6)

up7 = Conv2D(16, 3, activation='relu', padding='same')(

Conv2DTranspose(16, 5, activation='relu', padding="same", strides=2)(drop6))

merge7 = concatenate([drop1, up7], axis=3)

conv7 = Conv2D(16, 5, activation='relu', padding='same')(merge7)

drop7 = Dropout(0.6)(conv7)

conv8 = Conv2D(1, 1, activation='relu')(drop7)

model = Model(inputs=inputs, outputs=conv8)

opt = Adam()

model.compile(optimizer=opt, loss='mse', metrics=['accuracy'])

if pretrained_weights:

model.load_weights(pretrained_weights)

return model

相关推荐
engchina8 分钟前
如何在 Python 中忽略烦人的警告?
开发语言·人工智能·python
Dream_Snowar1 小时前
速通Python 第四节——函数
开发语言·python·算法
西猫雷婶1 小时前
python学opencv|读取图像(十四)BGR图像和HSV图像通道拆分
开发语言·python·opencv
汪洪墩2 小时前
【Mars3d】设置backgroundImage、map.scene.skyBox、backgroundImage来回切换
开发语言·javascript·python·ecmascript·webgl·cesium
程序员shen1616113 小时前
抖音短视频saas矩阵源码系统开发所需掌握的技术
java·前端·数据库·python·算法
人人人人一样一样3 小时前
作业Python
python
四口鲸鱼爱吃盐3 小时前
Pytorch | 利用VMI-FGSM针对CIFAR10上的ResNet分类器进行对抗攻击
人工智能·pytorch·python
四口鲸鱼爱吃盐4 小时前
Pytorch | 利用PI-FGSM针对CIFAR10上的ResNet分类器进行对抗攻击
人工智能·pytorch·python
小陈phd4 小时前
深度学习之超分辨率算法——SRCNN
python·深度学习·tensorflow·卷积