This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Refer to `https://j-towns.github.io/2017/06/12/A-new-trick.html` for math details. | |
import torch | |
from torch import nn | |
from torch import autograd | |
def get_jvp(net, x, v): | |
''' | |
Generate jacobian vector product. Requires x.requires_grad() | |
and v.requires_grad(). | |
Args: |