def preProc1(x):
# Access the global variables
global P,expP,negExpP
P = P.type_as(x)
expP = expP.type_as(x)
negExpP = negExpP.type_as(x)
# Create a variable filled with -1. Second part of the condition
z = Variable(torch.zeros(x.size()).fill_(-1)).type_as(x)
absX = torch.abs(x)
cond1 = torch.gt(absX, negExpP)
if (torch.sum(cond1) > 0).data.all():
x1 = torch.log(torch.abs(x[cond1]))/P
z[cond1] = x1
return z
评论列表
文章目录