Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difference between transform & target_transform? #215

Closed
isalirezag opened this issue Jul 30, 2017 · 12 comments
Closed

difference between transform & target_transform? #215

isalirezag opened this issue Jul 30, 2017 · 12 comments

Comments

@isalirezag
Copy link

Can you please explain the difference between transform & target_transform?
I understand that we usually use transform for doing changes to our images, but target_transform is still unclear for me? what is exactly used for? can we use that for images? the definition of it says: a function that takes in the target and transforms it, but it is not clear to me what it exactly means

@Cadene
Copy link

Cadene commented Jul 31, 2017

Lets say you want to apply some data augmentations over a dataset of images with their segmentation masks. If you rotate the image to the left with transform, you would have to rotate the mask to the left as well. That's one of the point of target_transform.

@isalirezag
Copy link
Author

cannot we just rotate both of them via transform?

@alykhantejani
Copy link
Contributor

@isalirezag currently the transform of the datasets only takes the input as an argument, hence the need for both a transform and a target_transform. However, there is a discussion in #230 to extend transforms to handle both input and target together.

cc @fmassa I think we can close this.

@fmassa fmassa closed this as completed Sep 3, 2017
@eduardo4jesus
Copy link

Lets say you want to apply some data augmentations over a dataset of images with their segmentation masks. If you rotate the image to the left with transform, you would have to rotate the mask to the left as well. That's one of the point of target_transform.

It took me a while to understand this explanation. So, I just want to highlight a term that @Cadene mentioned that should be in kept in mind in order to understand it right away.

For classification problems, the target are labels. Thus, target_transforms wouldn't make sense.
However, for segmentation problems, in which we have segmentation masks as targets, it totally make sense.

@fmassa
Copy link
Member

fmassa commented Jul 3, 2020

@eduardo4jesus I wouldn't say that target_transforms doesn't make sense for classification problems.
One could for example want to merge labels into common categories during training (say, via some sort of taxonomy), and the target_transform could be used for that.

@eduardo4jesus
Copy link

@fmassa. (Wow) That is true! Thank you so much. I hadn't thought about that usage!

@SmallPigPeppa
Copy link

Thank you a lot!!! very helpful answer

@andrew-miao
Copy link

@fmassa Cool! Thank you for your informational answer!

@chenfengshijie
Copy link

Very useful answer!

@brando90
Copy link

what is an example of what the target transform should be for a classification problem?

@EddieAy
Copy link

EddieAy commented Oct 22, 2022

@fmassa Thank you for your informational answer

@hanli435
Copy link

very helpful.thank you a lot!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests