You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
307 B
18 lines
307 B
7 years ago
|
from torch.autograd import Function
|
||
|
|
||
|
|
||
|
class ReverseLayerF(Function):
|
||
|
|
||
|
@staticmethod
|
||
|
def forward(ctx, x, alpha):
|
||
|
ctx.alpha = alpha
|
||
|
|
||
|
return x.view_as(x)
|
||
|
|
||
|
@staticmethod
|
||
|
def backward(ctx, grad_output):
|
||
|
output = grad_output.neg() * ctx.alpha
|
||
|
return output, None
|
||
|
|
||
|
|