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
Unet++ 网络tensorflow版(slim实现)
最新推荐文章于 2023-02-06 21:42:42 发布