SE Moudle pytorch

I am a pytorch beginner, recently regenerated deeplab v3 + pytorch code, downloaded github jzZhang code in learning, but I want to use this code to train their own data set, and add the attention mechanism into deeplab, I have SE’s tensorflow code but do not know how to write pytorch code, ask for help

Are you stuck at a specific point and need some information how to translate this particular code snippet to PyTorch?

I want to add this SE module to the ASPP to see if it can improve the accuracy of semantic segmentation. The tensorflow code of SE module is as follows:
def Global_Average_Pooling(x):
return global_avg_pool(x, name=‘Global_avg_pooling’)

def Dropout(x, rate, training) :
return tf.layers.dropout(inputs=x, rate=rate, training=training)

def Fully_connected(x, units):
return tf.layers.dense(inputs=x, use_bias=False, units=units)

def Squeeze_excitation_layer(inputs, n_filters):
net = Global_Average_Pooling(inputs)
net = Fully_connected(net, units=n_filters)
net = tf.nn.relu(net)
net = Fully_connected(net, units=n_filters)
net = tf.nn.sigmoid(net)
net = inputs * net
return net
I want to know how to convert this module to pytorch, because I just learned pytorch, and it can be converted to some basic statements, but this is a little difficult for me, I hope to get help

Hey, is it what you want?

1 Like

Thank you, it was useful to me