Skip to content

Instantly share code, notes, and snippets.

View bobvo23's full-sized avatar
🎯
Focusing

Bobby V bobvo23

🎯
Focusing
  • Canada
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import torch
def jacobian(y, x, create_graph=False):
jac = []
flat_y = y.reshape(-1)
grad_y = torch.zeros_like(flat_y)
for i in range(len(flat_y)):
grad_y[i] = 1.
grad_x, = torch.autograd.grad(flat_y, x, grad_y, retain_graph=True, create_graph=create_graph)
jac.append(grad_x.reshape(x.shape))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bobvo23
bobvo23 / configure_muliple_gcc.sh
Created May 27, 2019 19:46 — forked from SunnyRaj/configure_muliple_gcc.sh
Configure multiple GCC versions on ubuntu
#!/usr/bin/env bash
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo apt-get install -y gcc-4.8 g++-4.8 gcc-4.9 g++-4.9 gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10