what does this line of code do ?

return data.trn_ds.denorm(x)[2]

This is the doc for the function:

Reverse the normalization done to a batch of images.
    Arguments: arr: of shape/size (N,3,sz,sz)

So this undoes the image normalization on x.
The normalization is subtracting mean of the data and dividing by standard deviation. (This will be mean and stddev of ImageNet, when using a pretrained model!). Therefore this will take your images, multiply them by that same stddev and add the mean back to them.
The [2] just indexes the resulting tensor in the batch dimension, meaning it returns the third image of this batch. I would not see why this is a sensible thing to do tho, in the function you’re showing.

1 Like

very tanks to you!