Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Custom twice differentiable functions in Pytorch. | |
| Author: Arthur Mensch | |
| """ | |
| import torch | |
| import torch.nn as nn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################# | |
| # Utils | |
| ################# | |
| """ | |
| log2i(x) | |
| logrithm for integer pow of 2 | |
| """ | |
| function log2i(x::T)::T where T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # In[1]: | |
| import math | |
| import torch | |
| from torch.nn.parameter import Parameter | |
| import torch.nn.functional as F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |