DeepLabV3+ in Julia

Assume input images are 128x128 (including segmentations) and extract layers from the backbone ResNet50.
While calculating the loss values with Flux.dice_coeff_loss function, I got this error: “ERROR: MethodError: objects of type NTuple{4, Int64} are not callable.” Why did I get the error, and what does it mean?

ERROR: MethodError: objects of type NTuple{4, Int64} are not callable
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:0 [inlined]
[2] _pullback(ctx::Zygote.Context, f::NTuple{4, Int64}, args::Array{Float32, 4})
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:9
[3] macro expansion
@ ~/.julia/packages/Flux/18YZE/src/layers/basic.jl:53 [inlined]
[4] _pullback
@ ~/.julia/packages/Flux/18YZE/src/layers/basic.jl:53 [inlined]

The error means that you are trying to call a tuple with four elements, something like this:

julia> x = (1, 1, 1, 1)
(1, 1, 1, 1)

julia> x("something")
ERROR: MethodError: objects of type NTuple{4, Int64} are not callable
Stacktrace:
 [1] top-level scope
   @ REPL[14]:1

Why you are getting this error is hard to say without an MWE.

1 Like

And, for info, MWE stands for “minimum working example”: if you want people to help, you should post a cut-down version of your program (the more, the better) that still exhibits the error you are reporting, so that whoever reads your post can track the error down to something precise.

Thank you for helping me a lot.
I am assuming that the concatenation is the cause of the issue.
What do you think?

function ASPP(encode_layer)

    pool_size = (encode_layer[1], encode_layer[2])         

    # --- Image Pooling ---- assume Encode_layer comes in

    image_pool = Flux.Chain(
        Flux.MeanPool(pool_size), 
        Flux.Conv((1, 1), 1024=>128, pad=(1, 1), bias=Zeros(128)), 
        Flux.BatchNorm(128, relu),
        Flux.Upsample(:bilinear, size = pool_size)
    )      

    # --- 1x1 Conv ----

    one = Flux.Chain(
        Flux.Conv((1, 1), 1024=>128, pad=(1, 1), bias=Zeros(128)), 
        Flux.BatchNorm(128, relu)
    )

    # --- 3x3 Conv Rate 6 ----

    rate6 = Flux.Chain(
        Flux.Conv((3, 3), 1024=>128, pad=(1, 1), dilation=6, bias=Zeros(128)), 
        Flux.BatchNorm(128, relu)
    )

    # --- 3x3 Conv Rate 12 ----

    rate12 = Flux.Chain(
        Flux.Conv((3, 3), 1024=>128, pad=(1, 1), dilation=12, bias=Zeros(128)),
        Flux.BatchNorm(128, relu)
    )

    # --- 3x3 Conv Rate 18 ----

    rate18 = Flux.Chain(
        Flux.Conv((3, 3), 1024=>128, pad=(1, 1), dilation=18, bias=Zeros(128)), 
        Flux.BatchNorm(128, relu)
    )

    # After ASPP Part  

    # --- Concatenate ----

    concatenate = Flux.Chain(encode_layer -> cat(

                        image_pool(encode_layer),

                        one(encode_layer),

                        rate6(encode_layer),

                        rate12(encode_layer),

                        rate18(encode_layer); dims=3

                        )       
                    )            

    # --- 1x1 Conv for UpSamling ----

    for_up = Flux.Chain(
                    concatenate,
                    Flux.Conv((1, 1), 640=>128, pad=(1, 1), bias=Zeros(128)),
                    Flux.BatchNorm(128, relu)
                    )       

    return for_up

Thank you for your quick response first.
I tried to fix the issues, but still, I cannot solve them.

Thank you for your suggestion.
I was not sure how to write the code on the post as it was my first-time post.