Skip to content

Instantly share code, notes, and snippets.

View YingGwan's full-sized avatar
😃
Focusing

Yingjun YingGwan

😃
Focusing
View GitHub Profile
@YingGwan
YingGwan / torch_jacobian.py
Created November 26, 2022 11:08 — forked from sbarratt/torch_jacobian.py
Get the jacobian of a vector-valued function that takes batch inputs, in pytorch.
def get_jacobian(net, x, noutputs):
x = x.squeeze()
n = x.size()[0]
x = x.repeat(noutputs, 1)
x.requires_grad_(True)
y = net(x)
y.backward(torch.eye(noutputs))
return x.grad.data
# OpenMesh-Python Cheat Sheet
'''
documentation: https://openmesh-python.readthedocs.io/en/latest/
OpenMesh-Python official repository:
https://www.graphics.rwth-aachen.de:9000/OpenMesh/openmesh-python
C++ documentation:
https://www.openmesh.org/media/Documentations/OpenMesh-Doc-Latest/a04099.html
'''
import openmesh
import numpy as np