Metalhead.UNet output array limit

Cheers,

Would like to confirm if the yhat array output of Metalhead.UNet model is limited to [0:1] elements. Apparently its upper bound is higher than 1.

Model is instantiated as follows:

backbone = Metalhead.backbone( ResNet(50; pretrain=true) )
modelcpu = Metalhead.UNet((512,512), 3, 1, backbone)
model = modelcpu |> gpu;

Then, without training, model is excited with:

x = rand(Float32, (512,512,3,1) |> gpu
yhat = model(x)

Thanks in advance for clarifying.

Not currently on a computer, but as far as I remember, the output is not restricted to [0,1] by default.
You can actually just take a look at the model architecture in the REPL by just doing

julia> cpumodel

Take a look at the last lines to see if the output of the last transformation would be restricted to [0,1] (sigmoid/hardsigmoid) or not. I guess it’s just relu +/- batchnorm at the end.
That said, you can simply add a missing sigmoid/hardsigmoid at the end to get what you want.

Indeed, last layer is a (1,1) convolution followed by relu. For the record, code follows:

Chain(
Chain(
Conv((3, 3), 3 => 3, pad=1, bias=false), # 81 parameters
BatchNorm(3), # 6 parameters, plus 6
NNlib.relu,
Conv((3, 3), 3 => 3, pad=1, bias=false), # 81 parameters
BatchNorm(3), # 6 parameters, plus 6
),
Chain(
Conv((1, 1), 3 => 1, bias=false), # 3 parameters
BatchNorm(1, relu), # 2 parameters, plus 2