fixing named tensor unflatten example (#106921)

Fixes an example from the documentation [here](https://pytorch.org/docs/stable/named_tensor.html#manipulating-dimensions).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/106921
Approved by: https://github.com/zou3519
This commit is contained in:
Alexander Jipa 2023-08-22 18:00:10 +00:00 committed by PyTorch MergeBot
parent 28dc1a093f
commit 2e054037da

View file

@ -204,9 +204,9 @@ and :meth:`~Tensor.reshape`, but have more semantic meaning to someone reading t
>>> named_flat_imgs.names
('N', 'features')
>>> unflattened_imgs = imgs.view(32, 3, 128, 128)
>>> unflattened_named_imgs = named_flat_imgs.unflatten(
'features', [('C', 3), ('H', 128), ('W', 128)])
>>> unflattened_named_imgs = named_flat_imgs.unflatten('features', [('C', 3), ('H', 128), ('W', 128)])
>>> unflattened_named_imgs.names
('N', 'C', 'H', 'W')
.. _named_tensors_autograd-doc: