flâneur — a map of the web's best reading

torch.where — PyTorch 2.12 documentation

docs.pytorch.org · 328 words · saved by 1 readers

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