• Home
  • Raw
  • Download

Lines Matching full:names

8 Named Tensors allow users to give explicit names to tensor dimensions.
10 dimension names, avoiding the need to track dimensions by position.
11 In addition, named tensors use names to automatically check that APIs
12 are being used correctly at runtime, providing extra safety. Names can
23 Factory functions now take a new :attr:`names` argument that associates a name
28 >>> torch.zeros(2, 3, names=('N', 'C'))
30 [0., 0., 0.]], names=('N', 'C'))
33 ``tensor.names[i]`` is the name of dimension ``i`` of ``tensor``.
47 See :attr:`~Tensor.names` for restrictions on tensor names.
49 Use :attr:`~Tensor.names` to access the dimension names of a tensor and
54 >>> imgs = torch.randn(1, 2, 2, 3 , names=('N', 'C', 'H', 'W'))
55 >>> imgs.names
59 >>> renamed_imgs.names
69 >>> imgs = torch.randn(1, 2, 2, 3 , names=(None, 'C', 'H', 'W'))
70 >>> imgs.names
76 Named tensors use names to automatically check that APIs are being called
80 - **Check names**: an operator may perform automatic checks at runtime that
81 check that certain dimension names must match.
82 - **Propagate names**: name inference propagates names to output tensors.
84 All operations that support named tensors propagate names.
88 >>> x = torch.randn(3, 3, names=('N', 'C'))
89 >>> x.abs().names
98 Two names *match* if they are equal (string equality) or if at least one is ``None``.
101 ``unify(A, B)`` determines which of the names ``A`` and ``B`` to propagate to the outputs.
102 It returns the more *specific* of the two names, if they match. If the names do not match,
119 x = torch.randn(3, names=('X',))
121 z = torch.randn(3, names=('Z',))
123 **Check names**: check that the names of the two tensors *match*.
136 **Propagate names**: *unify* the names to select which one to propagate.
142 >>> (x + y).names
144 >>> (x + x).names
153 Explicit alignment by names
157 by name to a specified ordering. This is useful for performing "broadcasting by names".
168 >>> scale = torch.randn(num_channels, names=('C',))
169 >>> imgs = torch.rand(3, 3, 3, num_channels, names=('N', 'H', 'W', 'C'))
170 >>> more_imgs = torch.rand(3, num_channels, 3, 3, names=('N', 'C', 'H', 'W'))
171 >>> videos = torch.randn(3, num_channels, 3, 3, 3, names=('N', 'C', 'H', 'W', 'D')
204 >>> named_flat_imgs.names
208 >>> unflattened_named_imgs.names
217 names on all tensors. Gradient computation is still correct but we lose the
218 safety that names give us.
222 >>> x = torch.randn(3, names=('D',))
223 >>> weight = torch.randn(3, names=('D',), requires_grad=True)
233 # Ideally we'd check that the names of loss and grad_loss match but we don't yet.
289 For a comprehensive reference for how names are propagated through other PyTorch
295 .. autoattribute:: names
313 >>> imgs = torch.randn(32, 3, 128, 128, names=('N', 'C', 'H', 'W'))
315 >>> flat_imgs.names, flat_imgs.shape