我有下面的代码,我想将其翻译成 pytorch。在这种情况下,我正在寻找一种将 np.vectorize 转换为任何 pytorch 方式的方法
pytorch 472
原文标题 :I have the code below which I want to translate into pytorch. I’m looking for a way to translate np.vectorize to any pytorch way in this case
我需要将此代码翻译成 pytorch。下面给出的代码使用 np.vectorize。我正在寻找与此等效的 pytorch。
class SimplexPotentialProjection(object):
def __init__(self, potential, inversePotential, strong_convexity_const, precision = 1e-10):
self.inversePotential = inversePotential
self.gradPsi = np.vectorize(potential)
self.gradPsiInverse = np.vectorize(inversePotential)
self.precision = precision
self.strong_convexity_const = strong_convexity_const