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 of weight must also be broadcastable.

Parameters
Returns

torch.Tensor