pfhedge.nn.functional.bilerp¶
- pfhedge.nn.functional.bilerp(input1, input2, input3, input4, weight1, weight2)[source]¶
Does a bilinear interpolation of four tensors based on a scalar or tensor weights and returns the resulting tensor.
The output is given by
\[\begin{split}\text{output}_i & = (1 - w_1) (1 - w_2) \cdot \text{input1}_i + w_1 (1 - w_2) \cdot \text{input2}_i \\ & \quad + (1 - w_1) w_2 \cdot \text{input3}_i + w_1 w_2 \cdot \text{input4}_i ,\end{split}\]where \(w_1\) and \(w_2\) are the weights.
The shapes of inputs must be broadcastable. If
weight
is a tensor, then the shapes ofweight
must also be broadcastable.- Parameters
input1 (torch.Tensor) – The input tensor.
input2 (torch.Tensor) – The input tensor.
input3 (torch.Tensor) – The input tensor.
input4 (torch.Tensor) – The input tensor.
weight1 (float or torch.Tensor) – The weight tensor.
weight2 (float or torch.Tensor) – The weight tensor.
- Returns
torch.Tensor