Skip to content

Instantly share code, notes, and snippets.

View LemonPi's full-sized avatar

Johnson Zhong LemonPi

View GitHub Profile
@sbarratt
sbarratt / torch_jacobian.py
Created May 9, 2019 19:40
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
@bobchennan
bobchennan / gels.py
Created March 15, 2019 18:49
GELS with deriviative in pytorch
import torch
from torch.autograd import Function
class GELS(Function):
""" Efficient implementation of gels from
Nanxin Chen
bobchennan@gmail.com
"""
@staticmethod
def forward(ctx, A, b):
@vxgmichel
vxgmichel / aioudp.py
Last active February 15, 2024 00:12
High-level UDP endpoints for asyncio
"""Provide high-level UDP endpoints for asyncio.
Example:
async def main():
# Create a local UDP enpoint
local = await open_local_endpoint('localhost', 8888)
# Create a remote UDP enpoint, pointing to the first one
@LemonPi
LemonPi / vimrc
Last active September 9, 2020 21:47
vimrc
" Remember to install Vundle with git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" set nocompatible " be iMproved, required
" filetype off " required
" set the runtime path to include Vundle and initialize
" set rtp+=~/.vim/bundle/Vundle.vim
" call vundle#begin()
" let Vundle manage Vundle, required
" Plugin 'gmarik/Vundle.vim'