Unet++ 网络tensorflow版(slim实现)

import tensorflow as tf
import numpy as np
import tensorflow.contrib.slim as slim
import os
from tensorflow.data import Dataset

reg = slim.l2_regularizer(scale=0.001) 

def standard_unit(input_tensor, stage, nb_filter, kernel_size=3):
    x = slim.conv2d(input_tensor, nb_filter, [3, 3], rate=1,activation_fn=None, weights_regularizer=reg)
    x = slim.batch_norm(x)
    x = tf.nn.relu(x)
    #x = slim.dropout(x)
    x = slim.conv2d(x, nb_filter, [3, 3], rate=1, scope=stage,activation_fn=None,weights_regularizer=reg)
    x = slim.batch_norm(x)
    x = tf.nn.relu(x)
    #x = slim.dropout(x)
    return x

def upsample(x,num_outputs,batch_size=1):
    pool_size = 2
    input_wh=int(x.shape[1])
    in_channels=int(x.shape[-1])
    output_shape=(batch_size,input_wh*2,input_wh*2,num_outputs)
    deconv_filter = tf.Variable(tf.truncated_normal([pool_size, pool_size, num_outputs, in_channels], stddev=0.02))
    deconv = tf.nn.conv2d_transpose(x, deconv_filter, output_shape, strides=[1, pool_size, pool_size, 1])
    return deconv


def UNet_pp(inputs, reg,deep_supervision=False):  # Unet
    '''

     1-1---> 1-2 ---> 1-3 ---> 1-4 --->1-5
        \   /   \   /    \    /   \   /
         2-1 --->2-2 ---> 2-3 --->2-4
           \    /   \    /   \   /
            3-1 ---> 3-2 ---> 3-3
              \     /   \    / 
                4-1---> 4-2
                  
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值