torch.where — PyTorch 2.12 documentation
input (Tensor or Scalar) – value (if input is a scalar) or values selected at indices where condition is True other (Tensor or Scalar) – value (if other is a scalar) or values selected at indices where condition is False out (Tensor, optional) – the output tensor. A tensor of shape equal to the broadcasted shape of condition, input, other Tensor Example: torch.where(condition) is identical to torch.nonzero(condition, as_tuple=True). Note See also torch.nonzero(). Previous torch.vstack Next Stream Built with the PyData Sphinx Theme 0.15.4. previous torch.vstack next Stream Access comprehensive developer documentation for PyTorch Get in-depth tutorials for beginners and advanced developers Find development resources and get your questions answered Stay in touch for updates, event info, and the latest news By submitting this form, I consent to receive marketing emails from the LF and its projects regarding their events, training, research, developments, and related announcements. I unders
torch.where # torch. where ( condition , input , other , * , out = None ) → Tensor # Return a tensor of elements selected from either input or other , depending on condition . The operation is defined as: out i = { input i if condition i other i otherwise \text{out}_i = \begin{cases} \text{input}_i & \text{if } \text{condition}_i \\ \text{other}_i & \text{otherwise} \\ \end{cases} out i = { input i other i if condition i otherwise Note The tensors condition , input , other must be broadcastable . Parameters : condition ( BoolTensor ) – When True (nonzero), yield input, other
Explore this link on the map →related reading
- torch.index_select — PyTorch 2.12 documentationdocs.pytorch.org
- torch_geometric.utils - pytorch_geometric documentationpytorch-geometric.readthedocs.io
- torch.max — PyTorch 2.12 documentationdocs.pytorch.org
- Chapter 0: Fundamentals - ARENAlearn.arena.education
- PyTorch internals : ezyang's blogblog.ezyang.com
- torch.triu — PyTorch 2.12 documentationdocs.pytorch.org
- Tiny TPUtinytpu.com
- torch.Tensor — PyTorch 2.12 documentationdocs.pytorch.org
- torch.ones_like — PyTorch 2.12 documentationdocs.pytorch.org
- Tensors — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- ReLU — PyTorch 2.12 documentationdocs.pytorch.org
- torch.zeros_like — PyTorch 2.12 documentationdocs.pytorch.org