Issue
As below, I understand lambda y:... .
But the first Lambda(...) is a function?.
ds = datasets.FashionMNIST(
...
target_transform=Lambda(lambda y: torch.zeros(10, dtype=torch.float).scatter_(0, torch.tensor(y), value=1))
)
Solution
It's just a function in torchvision for wrapping an arbitrary function as a transform. It's nothing to do with Python syntax, and is spelled Lambda
with a capital L
instead of lambda
to not conflict with the Python keyword.
Answered By - Iguananaut
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.