Is there a polynomial evaluation function in PyTorch? Similar to https://www.tensorflow.org/api_docs/python/tf/math/polyval in Tensorflow, that automatically broadcasts over tensors?
You can have something like this
# POLYVAL in PYTORCH
coeffs=torch.FloatTensor([1.,2.,1.,1.])
x=torch.FloatTensor([3.0])
def getPolyVal(x,coeffs):
curVal=0
for curValIndex in range(len(coeffs)-1):
curVal=(curVal+coeffs[curValIndex])*x[0]
return(curVal+coeffs[len(coeffs)-1])
getPolyVal(x,coeffs)
1 Like
Thanks.
Any tricks I can do to make this as fast as possible?