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

Adds example of inferring dimensions. #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zimonitrome
Copy link

This feature is a nugget that might be obvious to some but is hidden in any documentation that I am able to find.

My edit might be on the nose of the readme but I otherwise suggest to include some other example to showcase inference of dimensions, e.g.:

image_sample = torch.rand([3, 256, 256])
image_batch = torch.rand([10, 3, 256, 256])

def make_grayscale(t):
    return reduce(t, "... c h w -> ... h w", "mean")

image_sample_gray = make_grayscale(image_sample)
image_batch_gray = make_grayscale(image_batch)

print(image_sample_gray.shape)
print(image_batch_gray.shape)

> [256, 256]
> [10, 256, 256]

@vmichals
Copy link

I assumed that this existed and should've guessed that the correct syntax is '...', but didn't! Luckily I saw your PR! Thanks!
I agree this is a very useful example for the documentation!

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

Successfully merging this pull request may close these issues.

None yet

2 participants