Data.c = 3

Hi folks,

I have a hopefully simple question!
In various lesson7 notebooks, basically all the ones on superres, when we create the DataBunch we define a function get_data to do it for us, like

def get_data(bs,size):
    data = (src.label_from_func(lambda x: path_hr/
           .transform(get_transforms(max_zoom=2.), size=size, tfm_y=True)
           .databunch(bs=bs).normalize(imagenet_stats, do_y=True))

    data.c = 3
    return data

but I can’t figure out what the data.c = 3 is there for! I know that in classification problems data.c is the number of classes and in general is the dimension of the last activation output of the NN … but why is it 3 here?

The output from the unet_type learner will be an image and in fact it is an image! So where does the ‘3’ comes from?



That’d be a 3 channel image, so RGB. It likely won’t actually alter the Unet output, but means more generic stuff will recognise there should be 3 outputs.


Brilliant ! I don’t know how I’ve missed that, thank!

Hi, sorry I still didn’t follow the answer.
I thought data.c slaps a final layer on resnet34 for classification.
The unet layer finally comes down to 28x28x1024 before scaling up according to the architecture.
Are you saying data.c in this case is specifying number of dimensions of final output?
Would really appreciate if someone could elaborate.

i think the second data.c(for the critic) is a mistake. The generator outputs a image and so data.c =3 for that makes sense.