Skip to content

Instantly share code, notes, and snippets.

View wangleiphy's full-sized avatar

Lei Wang wangleiphy

View GitHub Profile
@shoyer
shoyer / simple-jax-gmres.ipynb
Created July 7, 2020 21:11
Simple JAX GMRES
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@caryan
caryan / Quantum Optimal Control with SciML.ipynb
Created June 10, 2020 04:32
Quantum Optimal Control with SciML and Julia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GiggleLiu
GiggleLiu / naive_einsum.jl
Last active January 20, 2020 09:16
CUDAnative based einsum! on GPU - the prototype
using TupleTools
using Base.Cartesian
using CuArrays, CUDAnative
"""
A naive implementation of `einsum!`
* `ixs`: input tensor indices,
* `xs`: input tensors,
* `iy`: output tensor indices,
* `y`: accumulated tensor, notice it is initialized to 0 as output!
from jax.interpreters import ad
from jax.interpreters import partial_eval as pe
from jax import custom_transforms
from jax import core
from jax import grad
@custom_transforms
def f(x, y):
return x**2 + 3 * y
@kylemcdonald
kylemcdonald / ACAI (PyTorch).ipynb
Last active March 12, 2023 18:37
PyTorch ACAI (1807.07543).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / Adversarial Variational Bayes toy example.ipynb
Last active May 3, 2024 00:03
Adversarial Variational Bayes toy example in PyTorch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arthurmensch
arthurmensch / double_backward.py
Created May 19, 2018 10:25
Custom twice differentiable functions in Pytorch.
"""
Custom twice differentiable functions in Pytorch.
Author: Arthur Mensch
"""
import torch
import torch.nn as nn
@Roger-luo
Roger-luo / Register.jl
Created May 13, 2018 12:14
A naive quanutm register
#################
# Utils
#################
"""
log2i(x)
logrithm for integer pow of 2
"""
function log2i(x::T)::T where T
@guillefix
guillefix / lc.py
Last active May 10, 2020 14:00
temporal workaround to get Conv2dLocal to work in PyTorch
# coding: utf-8
# In[1]:
import math
import torch
from torch.nn.parameter import Parameter
import torch.nn.functional as F
@yaroslavvb
yaroslavvb / kfac_small_pytorch_test.py
Created October 19, 2017 15:23
toy example of KFAC in pytorch
# Times: min: 440.60, median: 452.39, mean: 453.87
import util as u
u.check_mkl()
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim