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

相关推荐
18你磊哥18 小时前
Django WEB 简单项目创建与结构讲解
前端·python·django·sqlite
月殇_木言19 小时前
Python期末复习
开发语言·python
BBB努力学习程序设计21 小时前
Python面向对象编程:从代码搬运工到架构师
python·pycharm
rising start21 小时前
五、python正则表达式
python·正则表达式
BBB努力学习程序设计21 小时前
Python错误处理艺术:从崩溃到优雅恢复的蜕变
python·pycharm
我叫黑大帅21 小时前
什么叫可迭代对象?为什么要用它?
前端·后端·python
Dillon Dong21 小时前
Django + uWSGI 部署至 Ubuntu 完整指南
python·ubuntu·django
k***82511 天前
python爬虫——爬取全年天气数据并做可视化分析
开发语言·爬虫·python
new_dev1 天前
Python网络爬虫从入门到实战
爬虫·python·媒体
q***01651 天前
Python爬虫完整代码拿走不谢
开发语言·爬虫·python