Image Segmentation with U-Net(吴恩达课程)

# UNQ_C1
# GRADED FUNCTION: conv_block
def conv_block(inputs=None, n_filters=32, dropout_prob=0, max_pooling=True):"""Convolutional downsampling blockArguments:inputs -- Input tensorn_filters -- Number of filters for the convolutional layersdropout_prob -- Dropout probabilitymax_pooling -- Use MaxPooling2D to reduce the spatial dimensions of the output volumeReturns: next_layer, skip_connection --  Next layer and skip connection outputs"""### START CODE HEREconv = Conv2D(n_filters, # Number of filters3,   # Kernel size   activation='relu',padding='same',kernel_initializer='he_normal')(inputs)conv = Conv2D(n_filters, # Number of filters3,   # Kernel sizeactivation='relu',padding='same',kernel_initializer='he_normal')(conv)### END CODE HERE# if dropout_prob > 0 add a dropout layer, with the variable dropout_prob as parameterif dropout_prob > 0:### START CODE HEREconv = Dropout(rate=dropout_prob)(conv)### END CODE HERE# if max_pooling is True add a MaxPooling2D with 2x2 pool_sizeif max_pooling:### START CODE HEREnext_layer = MaxPooling2D(2,2)(conv)### END CODE HEREelse:next_layer = convskip_connection = convreturn next_layer, skip_connection
# UNQ_C2
# GRADED FUNCTION: upsampling_block
def upsampling_block(expansive_input, contractive_input, n_filters=32):"""Convolutional upsampling blockArguments:expansive_input -- Input tensor from previous layercontractive_input -- Input tensor from previous skip layern_filters -- Number of filters for the convolutional layersReturns: conv -- Tensor output"""### START CODE HEREup = Conv2DTranspose(n_filters,    # number of filters3,    # Kernel sizestrides=2,padding='same')(expansive_input)# Merge the previous output and the contractive_inputmerge = concatenate([up, contractive_input], axis=3)conv = Conv2D(n_filters,   # Number of filters3,     # Kernel sizeactivation='relu',padding='same',kernel_initializer='he_normal')(merge)conv = Conv2D(n_filters,  # Number of filters3,   # Kernel sizeactivation='relu',padding='same',kernel_initializer='he_normal')(conv)### END CODE HEREreturn conv
# UNQ_C3
# GRADED FUNCTION: unet_model
def unet_model(input_size=(96, 128, 3), n_filters=32, n_classes=23):"""Unet modelArguments:input_size -- Input shape n_filters -- Number of filters for the convolutional layersn_classes -- Number of output classesReturns: model -- tf.keras.Model"""inputs = Input(input_size)# Contracting Path (encoding)# Add a conv_block with the inputs of the unet_ model and n_filters### START CODE HEREcblock1 = conv_block(inputs, n_filters)# Chain the first element of the output of each block to be the input of the next conv_block. # Double the number of filters at each new stepcblock2 = conv_block(cblock1[0], n_filters*2)cblock3 = conv_block(cblock2[0], n_filters*4)cblock4 = conv_block(cblock3[0], n_filters*8, dropout_prob=0.3) # Include a dropout of 0.3 for this layer# Include a dropout of 0.3 for this layer, and avoid the max_pooling layercblock5 = conv_block(cblock4[0],  n_filters*16, dropout_prob=0.3, max_pooling=False) ### END CODE HERE# Expanding Path (decoding)# Add the first upsampling_block.# Use the cblock5[0] as expansive_input and cblock4[1] as contractive_input and n_filters * 8### START CODE HEREublock6 = upsampling_block(cblock5[0], cblock4[1],  n_filters * 8)# Chain the output of the previous block as expansive_input and the corresponding contractive block output.# Note that you must use the second element of the contractive block i.e before the maxpooling layer. # At each step, use half the number of filters of the previous block ublock7 = upsampling_block(ublock6, cblock3[1], n_filters * 4)ublock8 = upsampling_block(ublock7, cblock2[1], n_filters * 2)ublock9 = upsampling_block(ublock8, cblock1[1], n_filters)### END CODE HEREconv9 = Conv2D(n_filters,3,activation='relu',padding='same',kernel_initializer='he_normal')(ublock9)# Add a Conv2D layer with n_classes filter, kernel size of 1 and a 'same' padding### START CODE HEREconv10 = Conv2D(n_classes, 1, padding='same')(conv9)### END CODE HEREmodel = tf.keras.Model(inputs=inputs, outputs=conv10)return model

Image Segmentation with U-Net(吴恩达课程)相关推荐

  1. Ex6_机器学习_吴恩达课程作业(Python):SVM支持向量机(Support Vector Machines)

    Ex6_机器学习_吴恩达课程作业(Python):SVM支持向量机(Support Vector Machines) 文章目录 Ex6_机器学习_吴恩达课程作业(Python):SVM支持向量机(Su ...

  2. Residual Networks(吴恩达课程)

    Residual Networks(吴恩达课程) # UNQ_C1 # GRADED FUNCTION: identity_blockdef identity_block(X, f, filters, ...

  3. Deep Learning Art: Neural Style Transfer(吴恩达课程)

    Deep Learning & Art: Neural Style Transfer(吴恩达课程) # UNQ_C1 # GRADED FUNCTION: compute_content_co ...

  4. Transfer Learning with MobileNetV2(吴恩达课程)

    Transfer Learning with MobileNetV2(吴恩达课程) # UNQ_C1 # GRADED FUNCTION: data_augmenter def data_augmen ...

  5. Autonomous Driving - Car Detection(吴恩达课程)

    Autonomous Driving - Car Detection(吴恩达课程) # UNQ_C1 (UNIQUE CELL IDENTIFIER, DO NOT EDIT) # GRADED FU ...

  6. 干货|机器学习零基础?不要怕,吴恩达课程笔记第三周!逻辑回归与正则

    吴恩达Coursera机器学习课系列笔记 课程笔记|吴恩达Coursera机器学习 Week1 笔记-机器学习基础 干货|机器学习零基础?不要怕,吴恩达机器学习课程笔记2-多元线性回归 1 Logis ...

  7. 吴恩达课程翻译_中文学习资源:斯坦福大学CS231n计算机视觉课程

    hi,我是为你们的xio习操碎了心的和鲸社区男运营 我们的网站:和鲸社区 Kesci.co 我们的公众号:和鲸社区(ID:heywhale-kesci) 有干货,来! 大家好,此次本鲸给大家翻译的项目 ...

  8. 吴恩达课程及视频笔记汇总

    马克一记https://zhuanlan.zhihu.com/p/30870804 转载于:https://www.cnblogs.com/573177885qq/p/7852564.html

  9. 【CNN】 吴恩达课程中几种网络的比较

    LeNet5 AlexNet VGG16 ResNet  : 残差网络 Inception Net :  特点,可以通过1*1*192 的卷积核来缩减参数个数,压缩维度,约缩减10倍, 例如  :用1 ...

最新文章

  1. mysql slave lock 跳过_处理 MySQL 因为 SLAVE 崩溃导致需要手动跳过 GTID 的问题 | 关于 GTID...
  2. oracle易忘函数用法(6)
  3. 用计算机数字技术制作的电影是,如何面对电影制作中的数字技术
  4. 如何在ASP.NET Core程序启动时运行异步任务(1)
  5. Python遍历破解FTP密码,并上传webshell
  6. [转载] Java7中增加的新特性
  7. cobbler装系统
  8. html超链接图标图片,HTML-标签:图片 超链接
  9. 决策树算法总结(下:CART决策树)
  10. HTML标签常用标签
  11. python报IndentationError: unexpected indent的解决方法.
  12. 山东教师教育网-404、登录、密码找回、常见问题、绑定已有账户
  13. 如何删除PDF空白签名域?
  14. 海思对接索尼ECX334 RGB OLED屏总结
  15. 关于数组的引用和引用的数组
  16. 可视化工具--Plotly
  17. 开源协议是什么?有哪些?如何选择?
  18. 京东到家库存设计(分布式系统)笔记
  19. 使用Hprose制作一个简单的分布式应用程序
  20. Unity实现体积雾与体积光

热门文章

  1. 企微网易互客SCRM与企鲸客scrm的功能有什么差别
  2. 新一季财报好未来 VS 新东方:谁的业绩更经得起“挑刺”?
  3. 23种设计模式(6)-适配器模式
  4. 云计算厂商抢占“东数西算”新商机
  5. 程序员的十个等级 你属于哪个等级
  6. 美团二面:为什么Redis会有哨兵?
  7. Ubuntu 设置文件默认打开的应用
  8. 微服务架构设计模式学习笔记——六边形架构
  9. 项目经理如何有效管理项目预算?
  10. 如何用excel筛选相似内容_excel如何筛选出相似的内容?