YouTip LogoYouTip

Pytorch Torch Fmax

# PyTorch torch.fmax Function * * * [![Image 3: Pytorch torch Reference Manual]( Pytorch torch Reference Manual]( `torch.fmax` is a function in PyTorch used for element-wise maximum value calculation (ignoring NaN). When the input contains NaN, torch.maximum returns NaN, while torch.fmax ignores NaN and returns the non-NaN value. ### Function Definition torch.fmax(input, other) * * * ## Usage Example ## Example import torch # Create tensors containing NaN x = torch.tensor([3.0,float('nan'),4.0]) y = torch.tensor([1.0,5.0,2.0]) # Element-wise maximum (ignoring NaN) result = torch.fmax(x, y) print(result) Output: tensor([3., 5., 4.]) * * * [![Image 4: Pytorch torch Reference Manual]( Pytorch torch Reference Manual](
← Pytorch Torch FmodPytorch Torch Floor β†’