Skip to content

Instantly share code, notes, and snippets.

View christian-cahig's full-sized avatar

Christian Cahig christian-cahig

View GitHub Profile
@christian-cahig
christian-cahig / torch_jacobian.py
Created January 10, 2022 02:21 — 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
@christian-cahig
christian-cahig / Extract-TarGz.ps1
Created January 7, 2022 04:10 — forked from jermdavis/Extract-TarGz.ps1
A PowerShell script that can extract .tar.gz files on Windows - with minimal dependencies to make it easy to use on servers.
[cmdletbinding(SupportsShouldProcess=$True)]
param(
# What .tar.gz file should be extracted? Must exist.
[Parameter(Mandatory=$True)]
[string]$FileToExtract,
# What folder should the files be extracted into? Does not need to exist
[Parameter(Mandatory=$True)]
[string]$TargetFolder,