In your code, drop_out=True
|
self.up4 = SE_Conv_Block(filters[4], filters[3], drop_out=True) |
|
self.conv4 = conv_block(filters[2], filters[3], drop_out=True) |
|
self.center = conv_block(filters[3], filters[4], drop_out=True) |
|
if self.dropout: |
|
out = nn.Dropout2d(0.5)(out) |
I think this line of code will affect the results when testing. Because you init the dropout layer in forward function, the model.eval() can not change the status of this layer.
You can test it with the following code
import torch
from torch import nn
import numpy as np
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.out = nn.Dropout2d(0.5)
def forward(self, x):
out = nn.Dropout2d(0.5)(x)
# out = self.out(x)
return out
if __name__ == '__main__':
model = Net()
model.eval()
input_npy = np.array([[1.0, 2.0], [3.0, 4.0]])
input_tensor = torch.from_numpy(input_npy)
output = model(input_tensor)
print(output)
If I didn't understand your code correctly, sorry in advance
In your code,
drop_out=TrueCA-Net/Models/networks/network.py
Line 55 in 94f2624
CA-Net/Models/networks/network.py
Line 36 in 94f2624
CA-Net/Models/networks/network.py
Line 39 in 94f2624
CA-Net/Models/layers/channel_attention_layer.py
Lines 95 to 96 in 94f2624
I think this line of code will affect the results when testing. Because you init the dropout layer in
forwardfunction, themodel.eval()can not change the status of this layer.You can test it with the following code
If I didn't understand your code correctly, sorry in advance