Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update layer_utils.py #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion keras_unet_collection/layer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from tensorflow.keras.layers import Conv2D, DepthwiseConv2D, Lambda
from tensorflow.keras.layers import BatchNormalization, Activation, concatenate, multiply, add
from tensorflow.keras.layers import ReLU, LeakyReLU, PReLU, ELU, Softmax
from tensorflow.keras.layers import Dropout

def decode_layer(X, channel, pool_size, unpool, kernel_size=3,
activation='ReLU', batch_norm=False, name='decode'):
Expand Down Expand Up @@ -196,7 +197,7 @@ def attention_gate(X, g, channel,

def CONV_stack(X, channel, kernel_size=3, stack_num=2,
dilation_rate=1, activation='ReLU',
batch_norm=False, name='conv_stack'):
batch_norm=False, dropout=False, dropout_rate=0.5, name='conv_stack'):
'''
Stacked convolutional layers:
(Convolutional layer --> batch normalization --> Activation)*stack_num
Expand Down Expand Up @@ -241,6 +242,11 @@ def CONV_stack(X, channel, kernel_size=3, stack_num=2,
activation_func = eval(activation)
X = activation_func(name='{}_{}_activation'.format(name, i))(X)

#dropout
if dropout:
X = Dropout(rate=dropout_rate)(X)


return X

def Res_CONV_stack(X, X_skip, channel, res_num, activation='ReLU', batch_norm=False, name='res_conv'):
Expand Down