'scipy .integrate.quad over a pytorch tensor

I'm trying to implement a solution concept for an auction setting as proposed in a paper. However, the integral calculation should be from 0 to \theta, where \theta is a one-dimensional Pytorch tensor. Here is the original function:

where ß(.) is a function of \theta and \theta_{min}=0. Since \alpha=1 in my setting, I am only interested in the numerator. I want to take the integral for all values stored in the \theta tensor and then save them into a tensor again. What I tried is the following:

v = integrate.quad(lambda self,s: (torch.Tensor(s)**2)*(1-(eta_loss*(mu_loss-1))*(1-torch.Tensor(s))), 
                              lambda valuation:0, lambda self, valuation:valuation)
        return (valuation**2)*(1-(eta_loss*(mu_loss-1))*(1-valuation))-v

where

(valuation**2)*(1-(eta_loss*(mu_loss-1))*(1-valuation)

is ß(.) function.

However, this resulted in the following error:

TypeError: '<' not supported between instances of 'function' and 'function'

Since this did not work out as expected, I tried the following:

v = integrate.dblquad(lambda self,s: (torch.Tensor(s)**2)*(1-(eta_loss*(mu_loss-1))*(1-torch.Tensor(s))), 
                              0, float('inf'), #inner integral
                              lambda valuation:0, lambda self, valuation:valuation) #outer integral
 return (valuation**2)*(1-(eta_loss*(mu_loss-1))*(1-valuation))-v

However, this gives me the following error:

TypeError: <lambda>() missing 1 required positional argument: 'valuation'

Does anybody have an idea on how to implement this? Thanks a lot in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source