repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
steer | steer-master/ffjord/datasets/gas.py | import pandas as pd
import numpy as np
import datasets
class GAS:
class Data:
def __init__(self, data):
self.x = data.astype(np.float32)
self.N = self.x.shape[0]
def __init__(self):
file = datasets.root + 'gas/ethylene_CO.pickle'
trn, val, tst = load_data_... | 1,672 | 21.917808 | 59 | py |
steer | steer-master/ffjord/datasets/bsds300.py | import numpy as np
import h5py
import datasets
class BSDS300:
"""
A dataset of patches from BSDS300.
"""
class Data:
"""
Constructs the dataset.
"""
def __init__(self, data):
self.x = data[:]
self.N = self.x.shape[0]
def __init__(self):
... | 663 | 17.971429 | 66 | py |
steer | steer-master/ffjord/datasets/miniboone.py | import numpy as np
import datasets
class MINIBOONE:
class Data:
def __init__(self, data):
self.x = data.astype(np.float32)
self.N = self.x.shape[0]
def __init__(self):
file = datasets.root + 'miniboone/data.npy'
trn, val, tst = load_data_normalised(file)
... | 1,955 | 26.942857 | 96 | py |
steer | steer-master/ffjord/datasets/__init__.py | root = 'data/'
from .power import POWER
from .gas import GAS
from .hepmass import HEPMASS
from .miniboone import MINIBOONE
from .bsds300 import BSDS300
| 153 | 18.25 | 32 | py |
steer | steer-master/ffjord/diagnostics/plot_sn_losses.py | import re
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
CIFAR10 = "diagnostics/cifar10_multiscale.log"
CIFAR10_SN = "diagnostics/cifar10_multiscale_sn.log"
MNIST = "diagnostics/mnist_multiscale.log"
MNIST_SN = "diagnostics/mnist_multiscale_sn.log"
def get_values(filename):
with open(fi... | 2,407 | 28.365854 | 93 | py |
steer | steer-master/ffjord/diagnostics/scrap_log.py | import os
import re
import csv
def log_to_csv(log_filename, csv_filename):
with open(log_filename, 'r') as f:
lines = f.readlines()
with open(csv_filename, 'w', newline='') as csvfile:
fieldnames = None
writer = None
for line in lines:
if line.startswith('Iter'):
... | 1,925 | 28.630769 | 107 | py |
steer | steer-master/ffjord/diagnostics/plot_nfe_vs_dim_vae.py | import os.path
import re
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import scipy.ndimage
import seaborn as sns
sns.set_style("whitegrid")
colors = ["windows blue", "amber", "greyish", "faded green", "dusty purple"]
sns.palplot(sns.xkcd_palette(colors))
dims = [16, 32, 4... | 1,443 | 27.313725 | 76 | py |
steer | steer-master/ffjord/diagnostics/viz_toy.py | import os
import math
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import torch
def standard_normal_logprob(z):
logZ = -0.5 * math.log(2 * math.pi)
return logZ - z.pow(2) / 2
def makedirs(dirname):
if not os.path.exists(dirname):
os.makedirs(dirname)... | 7,028 | 38.05 | 119 | py |
steer | steer-master/ffjord/diagnostics/plot_losses.py | import re
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
CIFAR10 = "diagnostics/cifar10_multiscale.log"
CIFAR10_SN = "diagnostics/cifar10_multiscale_sn.log"
MNIST = "diagnostics/mnist_multiscale.log"
MNIST_SN = "diagnostics/mnist_multiscale_sn.log"
def get_values(filename):
with open(fi... | 2,407 | 28.365854 | 93 | py |
steer | steer-master/ffjord/diagnostics/viz_cnf.py | from inspect import getsourcefile
import sys
import os
import subprocess
current_path = os.path.abspath(getsourcefile(lambda: 0))
current_dir = os.path.dirname(current_path)
parent_dir = current_dir[:current_dir.rfind(os.path.sep)]
sys.path.insert(0, parent_dir)
import argparse
import torch
import torchvision.dataset... | 9,576 | 36.120155 | 107 | py |
steer | steer-master/ffjord/diagnostics/viz_fig1.py | import os
import math
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import torch
from scipy import interpolate as interp
import lib.utils as utils
def standard_normal_logprob(z):
logZ = -0.5 * math.log(2 * math.pi)
return logZ - z.pow(2) / 2
def makedirs(dirname):... | 54,154 | 42.04849 | 172 | py |
steer | steer-master/ffjord/diagnostics/approx_error_1d_particle_traj.py | from inspect import getsourcefile
import sys
import os
current_path = os.path.abspath(getsourcefile(lambda: 0))
current_dir = os.path.dirname(current_path)
parent_dir = current_dir[:current_dir.rfind(os.path.sep)]
sys.path.insert(0, parent_dir)
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
f... | 15,540 | 36.720874 | 116 | py |
steer | steer-master/ffjord/diagnostics/plot_bottleneck_losses.py | import re
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import scipy.signal
import scipy.ndimage
# BASE = "experiments/cnf_mnist_64-64-128-128-64-64/logs"
# RESIDUAL = "experiments/cnf_mnist_64-64-128-128-64-64_residual/logs"
# RADEMACHER = "experiments/cnf_mnist_64-64-128-... | 2,848 | 39.126761 | 144 | py |
steer | steer-master/ffjord/diagnostics/plot_flows.py | from inspect import getsourcefile
import sys
import os
current_path = os.path.abspath(getsourcefile(lambda: 0))
current_dir = os.path.dirname(current_path)
parent_dir = current_dir[:current_dir.rfind(os.path.sep)]
sys.path.insert(0, parent_dir)
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
... | 6,070 | 37.424051 | 119 | py |
steer | steer-master/ffjord/diagnostics/viz_high_fidelity_toy.py | import os
import math
from tqdm import tqdm
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import torch
def standard_normal_logprob(z):
logZ = -0.5 * math.log(2 * math.pi)
return logZ - z.pow(2) / 2
def makedirs(dirname):
if not os.path.exists(dirname):
... | 5,114 | 37.458647 | 119 | py |
steer | steer-master/ffjord/diagnostics/approx_error_1d.py | from inspect import getsourcefile
import sys
import os
current_path = os.path.abspath(getsourcefile(lambda: 0))
current_dir = os.path.dirname(current_path)
parent_dir = current_dir[:current_dir.rfind(os.path.sep)]
sys.path.insert(0, parent_dir)
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
f... | 12,572 | 36.984894 | 116 | py |
steer | steer-master/ffjord/diagnostics/fig_1_1d_toy.py | import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from inspect import getsourcefile
import sys
import argparse
import os
import time
current_path = os.path.abspath(getsourcefile(lambda: 0))
current_dir = os.path.dirname(current_path)
parent_dir = current_dir[:current_dir.rfind(os.path.sep)]
sys.p... | 12,538 | 41.795222 | 166 | py |
steer | steer-master/ffjord/diagnostics/plot_compare_multiscale.py | import re
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
MNIST_SINGLESCALE = "diagnostics/mnist.log"
MNIST_MULTISCALE = "diagnostics/mnist_multiscale.log"
def get_values(filename):
with open(filename, "r") as f:
lines = f.readlines()
losses = []
nfes = []
for line i... | 1,868 | 29.639344 | 118 | py |
steer | steer-master/ffjord/diagnostics/viz_multiscale.py | from inspect import getsourcefile
import sys
import os
import math
current_path = os.path.abspath(getsourcefile(lambda: 0))
current_dir = os.path.dirname(current_path)
parent_dir = current_dir[:current_dir.rfind(os.path.sep)]
sys.path.insert(0, parent_dir)
import argparse
import lib.layers as layers
import lib.odenv... | 8,489 | 37.071749 | 119 | py |
steer | steer-master/ffjord/lib/priors.py | import math
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
eps = 1e-8
class Uniform(nn.Module):
def __init__(self, a=0, b=1):
super(Normal, self).__init__()
self.a = Variable(torch.Tensor([a]))
self.b = Variable(torch.Tensor([b]))
def _che... | 8,414 | 32.392857 | 84 | py |
steer | steer-master/ffjord/lib/spectral_norm.py | """
Spectral Normalization from https://arxiv.org/abs/1802.05957
"""
import types
import torch
from torch.nn.functional import normalize
POWER_ITERATION_FN = "spectral_norm_power_iteration"
class SpectralNorm(object):
def __init__(self, name='weight', dim=0, eps=1e-12):
self.name = name
self.dim ... | 6,512 | 38.957055 | 119 | py |
steer | steer-master/ffjord/lib/utils.py | import os
import math
from numbers import Number
import logging
import torch
def makedirs(dirname):
if not os.path.exists(dirname):
os.makedirs(dirname)
def get_logger(logpath, filepath, package_files=[], displaying=True, saving=True, debug=False):
logger = logging.getLogger()
if debug:
... | 3,046 | 24.822034 | 95 | py |
steer | steer-master/ffjord/lib/odenvp.py | import torch
import torch.nn as nn
import lib.layers as layers
from lib.layers.odefunc import ODEnet
import numpy as np
class ODENVP(nn.Module):
"""
Real NVP for image data. Will downsample the input until one of the
dimensions is less than or equal to 4.
Args:
input_size (tuple): 4D tuple of... | 6,008 | 34.556213 | 116 | py |
steer | steer-master/ffjord/lib/datasets.py | import torch
class Dataset(object):
def __init__(self, loc, transform=None):
self.dataset = torch.load(loc).float().div(255)
self.transform = transform
def __len__(self):
return self.dataset.size(0)
@property
def ndim(self):
return self.dataset.size(1)
def __geti... | 725 | 24.928571 | 97 | py |
steer | steer-master/ffjord/lib/multiscale_parallel.py | import torch
import torch.nn as nn
import lib.layers as layers
from lib.layers.odefunc import ODEnet
import numpy as np
class MultiscaleParallelCNF(nn.Module):
"""
CNF model for image data.
Squeezes the input into multiple scales, applies different conv-nets at each scale
and adds the resulting gradi... | 5,203 | 31.525 | 113 | py |
steer | steer-master/ffjord/lib/toy_data.py | import numpy as np
import sklearn
import sklearn.datasets
from sklearn.utils import shuffle as util_shuffle
# Dataset iterator
def inf_train_gen(data, rng=None, batch_size=200):
if rng is None:
rng = np.random.RandomState()
if data == "swissroll":
data = sklearn.datasets.make_swiss_roll(n_sam... | 4,517 | 36.032787 | 112 | py |
steer | steer-master/ffjord/lib/custom_optimizers.py | import math
import torch
from torch.optim.optimizer import Optimizer
class Adam(Optimizer):
"""Implements Adam algorithm.
It has been proposed in `Adam: A Method for Stochastic Optimization`_.
Arguments:
params (iterable): iterable of parameters to optimize or dicts defining
paramete... | 4,597 | 41.574074 | 116 | py |
steer | steer-master/ffjord/lib/visualize_flow.py | import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import torch
LOW = -4
HIGH = 4
def plt_potential_func(potential, ax, npts=100, title="$p(x)$"):
"""
Args:
potential: computes U(z_k) given z_k
"""
xside = np.linspace(LOW, HIGH, npts)
yside = np.lin... | 4,341 | 31.646617 | 118 | py |
steer | steer-master/ffjord/lib/layers/squeeze.py | import torch.nn as nn
__all__ = ['SqueezeLayer']
class SqueezeLayer(nn.Module):
def __init__(self, downscale_factor):
super(SqueezeLayer, self).__init__()
self.downscale_factor = downscale_factor
def forward(self, x, logpx=None, reverse=False):
if reverse:
return self._up... | 1,955 | 29.5625 | 119 | py |
steer | steer-master/ffjord/lib/layers/container.py | import torch.nn as nn
class SequentialFlow(nn.Module):
"""A generalized nn.Sequential container for normalizing flows.
"""
def __init__(self, layersList):
super(SequentialFlow, self).__init__()
self.chain = nn.ModuleList(layersList)
def forward(self, x, logpx=None, reverse=False, ind... | 766 | 27.407407 | 67 | py |
steer | steer-master/ffjord/lib/layers/norm_flows.py | import math
import torch
import torch.nn as nn
from torch.autograd import grad
class PlanarFlow(nn.Module):
def __init__(self, nd=1):
super(PlanarFlow, self).__init__()
self.nd = nd
self.activation = torch.tanh
self.register_parameter('u', nn.Parameter(torch.randn(self.nd)))
... | 2,240 | 31.014286 | 101 | py |
steer | steer-master/ffjord/lib/layers/cnf.py | import torch
import torch.nn as nn
#from torchdiffeq import odeint_adjoint_stochastic_end_v2
from torchdiffeq import odeint_adjoint_stochastic_end_v3
from torchdiffeq import odeint_adjoint_stochastic_end_normal
from torchdiffeq import odeint_adjoint as odeint
#from torchdiffeq import odeint
from .wrappers.cnf_regula... | 3,561 | 32.92381 | 118 | py |
steer | steer-master/ffjord/lib/layers/odefunc.py | import copy
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from . import diffeq_layers
from .squeeze import squeeze, unsqueeze
__all__ = ["ODEnet", "AutoencoderDiffEqNet", "ODEfunc", "AutoencoderODEfunc"]
def divergence_bf(dx, y, **unused_kwargs):
sum_diag = 0.
for i i... | 12,985 | 34.675824 | 114 | py |
steer | steer-master/ffjord/lib/layers/resnet.py | import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, dim):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(dim, dim, kernel_size=3, padding=1, bias=False)
self.bn1 = nn.GroupNorm(2, dim, eps=1e-4)
self.re... | 2,335 | 35.5 | 107 | py |
steer | steer-master/ffjord/lib/layers/glow.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class BruteForceLayer(nn.Module):
def __init__(self, dim):
super(BruteForceLayer, self).__init__()
self.weight = nn.Parameter(torch.eye(dim))
def forward(self, x, logpx=None, reverse=False):
if not reverse:
... | 836 | 26 | 76 | py |
steer | steer-master/ffjord/lib/layers/elemwise.py | import math
import torch
import torch.nn as nn
_DEFAULT_ALPHA = 1e-6
class ZeroMeanTransform(nn.Module):
def __init__(self):
nn.Module.__init__(self)
def forward(self, x, logpx=None, reverse=False):
if reverse:
x = x + .5
if logpx is None:
return x
... | 1,918 | 24.25 | 84 | py |
steer | steer-master/ffjord/lib/layers/__init__.py | from .elemwise import *
from .container import *
from .cnf import *
from .odefunc import *
from .squeeze import *
from .normalization import *
from . import diffeq_layers
from .coupling import *
from .glow import *
from .norm_flows import *
| 241 | 21 | 28 | py |
steer | steer-master/ffjord/lib/layers/normalization.py | import torch
import torch.nn as nn
from torch.nn import Parameter
__all__ = ['MovingBatchNorm1d', 'MovingBatchNorm2d']
class MovingBatchNormNd(nn.Module):
def __init__(self, num_features, eps=1e-4, decay=0.1, bn_lag=0., affine=True):
super(MovingBatchNormNd, self).__init__()
self.num_features = n... | 4,688 | 32.978261 | 100 | py |
steer | steer-master/ffjord/lib/layers/coupling.py | import torch
import torch.nn as nn
__all__ = ['CouplingLayer', 'MaskedCouplingLayer']
class CouplingLayer(nn.Module):
"""Used in 2D experiments."""
def __init__(self, d, intermediate_dim=64, swap=False):
nn.Module.__init__(self)
self.d = d - (d // 2)
self.swap = swap
self.net... | 3,525 | 30.20354 | 101 | py |
steer | steer-master/ffjord/lib/layers/wrappers/cnf_regularization.py | import torch
import torch.nn as nn
class RegularizedODEfunc(nn.Module):
def __init__(self, odefunc, regularization_fns):
super(RegularizedODEfunc, self).__init__()
self.odefunc = odefunc
self.regularization_fns = regularization_fns
def before_odeint(self, *args, **kwargs):
sel... | 3,591 | 31.654545 | 115 | py |
steer | steer-master/ffjord/lib/layers/diffeq_layers/container.py | import torch
import torch.nn as nn
from .wrappers import diffeq_wrapper
class SequentialDiffEq(nn.Module):
"""A container for a sequential chain of layers. Supports both regular and diffeq layers.
"""
def __init__(self, *layers):
super(SequentialDiffEq, self).__init__()
self.layers = nn.... | 1,357 | 30.581395 | 106 | py |
steer | steer-master/ffjord/lib/layers/diffeq_layers/resnet.py | import torch.nn as nn
from . import basic
from . import container
NGROUPS = 16
class ResNet(container.SequentialDiffEq):
def __init__(self, dim, intermediate_dim, n_resblocks, conv_block=None):
super(ResNet, self).__init__()
if conv_block is None:
conv_block = basic.ConcatCoordConv2... | 2,003 | 28.470588 | 99 | py |
steer | steer-master/ffjord/lib/layers/diffeq_layers/wrappers.py | from inspect import signature
import torch.nn as nn
__all__ = ["diffeq_wrapper", "reshape_wrapper"]
class DiffEqWrapper(nn.Module):
def __init__(self, module):
super(DiffEqWrapper, self).__init__()
self.module = module
if len(signature(self.module.forward).parameters) == 1:
se... | 1,365 | 28.06383 | 104 | py |
steer | steer-master/ffjord/lib/layers/diffeq_layers/__init__.py | from .container import *
from .resnet import *
from .basic import *
from .wrappers import *
| 92 | 17.6 | 24 | py |
steer | steer-master/ffjord/lib/layers/diffeq_layers/basic.py | import torch
import torch.nn as nn
import torch.nn.functional as F
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Linear') != -1 or classname.find('Conv') != -1:
nn.init.constant_(m.weight, 0)
nn.init.normal_(m.bias, 0, 0.01)
class HyperLinear(nn.Module):
def __... | 11,057 | 36.869863 | 120 | py |
steer | steer-master/latent_ode/mujoco_physics.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Authors: Yulia Rubanova and Ricky Chen
###########################
import os
import numpy as np
import torch
from lib.utils import get_dict_template
import lib.utils as utils
from torchvision.datasets.utils import download_url
class Hoppe... | 4,315 | 27.966443 | 92 | py |
steer | steer-master/latent_ode/person_activity.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Authors: Yulia Rubanova and Ricky Chen
###########################
import os
import lib.utils as utils
import numpy as np
import tarfile
import torch
from torch.utils.data import DataLoader
from torchvision.datasets.utils import download_... | 9,173 | 29.682274 | 120 | py |
steer | steer-master/latent_ode/generate_timeseries.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
# Create a synthetic dataset
from __future__ import print_function
from __future__ import absolute_import, division
import lib.utils as utils
import torch
import matplotlib.image
import ma... | 5,248 | 33.761589 | 131 | py |
steer | steer-master/latent_ode/physionet.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Authors: Yulia Rubanova and Ricky Chen
###########################
import os
import matplotlib
if os.path.exists("/Users/yulia"):
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
import matplotlib.pyplot
import matplotlib.pyplot as pl... | 11,603 | 31.233333 | 114 | py |
steer | steer-master/latent_ode/run_models.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import os
import sys
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot
import matplotlib.pyplot as plt
import time
import datetime
import argparse
import numpy as np
import... | 13,141 | 38.584337 | 170 | py |
steer | steer-master/latent_ode/lib/rnn_baselines.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.utils import get_device
from lib.encoder_decoder import *
fro... | 14,730 | 32.177928 | 121 | py |
steer | steer-master/latent_ode/lib/create_latent_ode_model.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import os
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.latent_ode import LatentODE
from lib.encoder_decod... | 3,325 | 30.377358 | 101 | py |
steer | steer-master/latent_ode/lib/ode_rnn.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.encoder_decoder import *
from lib.likelihood_eval import *
f... | 3,133 | 31.309278 | 121 | py |
steer | steer-master/latent_ode/lib/plotting.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import matplotlib
# matplotlib.use('TkAgg')
matplotlib.use('Agg')
import matplotlib.pyplot
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import os
from scipy.stats i... | 16,053 | 33.673866 | 125 | py |
steer | steer-master/latent_ode/lib/diffeq_solver.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import time
import numpy as np
import torch
import torch.nn as nn
import lib.utils as utils
from torch.distributions.multivariate_normal import MultivariateNormal
# git clone https://gi... | 2,845 | 37.986301 | 126 | py |
steer | steer-master/latent_ode/lib/ode_func.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import torch
import torch.nn as nn
from torch.nn.utils.spectral_norm import spectral_norm
import lib.utils as utils
###################################################... | 3,935 | 32.641026 | 135 | py |
steer | steer-master/latent_ode/lib/latent_ode.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import sklearn as sk
import numpy as np
#import gc
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.utils impo... | 4,826 | 33.478571 | 99 | py |
steer | steer-master/latent_ode/lib/likelihood_eval.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import gc
import numpy as np
import sklearn as sk
import numpy as np
#import gc
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.... | 9,166 | 33.592453 | 114 | py |
steer | steer-master/latent_ode/lib/utils.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import os
import logging
import pickle
import torch
import torch.nn as nn
import numpy as np
import pandas as pd
import math
import glob
import re
from shutil import copyfile
import skle... | 18,626 | 28.660828 | 149 | py |
steer | steer-master/latent_ode/lib/encoder_decoder.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from torch.distributions import Categorical, Normal
import lib.utils as... | 9,918 | 28.520833 | 130 | py |
steer | steer-master/latent_ode/lib/base_models.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import relu
import lib.utils as utils
from lib.encoder_decoder import *
from lib.likelihood_eval import *
f... | 11,032 | 31.072674 | 112 | py |
steer | steer-master/latent_ode/lib/parse_datasets.py | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import os
import numpy as np
import torch
import torch.nn as nn
import lib.utils as utils
from lib.diffeq_solver import DiffeqSolver
from generate_timeseries import Periodic_1d
from torc... | 9,406 | 37.871901 | 135 | py |
steer | steer-master/stiff_ode_experiments/stiff_ode_demo.py | import os
import argparse
import time
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
parser = argparse.ArgumentParser('ODE demo')
parser.add_argument('--method', type=str, choices=['dopri5', 'adams'], default='dopri5')
parser.add_argument('--data_size', type=int, d... | 5,987 | 32.452514 | 161 | py |
steer | steer-master/torchdiffeq/setup.py | import setuptools
setuptools.setup(
name="torchdiffeq",
version="0.0.1",
author="Ricky Tian Qi Chen",
author_email="rtqichen@cs.toronto.edu",
description="ODE solvers and adjoint sensitivity analysis in PyTorch.",
url="https://github.com/arnabgho/torchdiffeq",
packages=['torchdiffeq', 'torc... | 443 | 30.714286 | 75 | py |
steer | steer-master/torchdiffeq/tests/gradient_tests.py | import unittest
import torch
import torchdiffeq
from problems import construct_problem
eps = 1e-12
torch.set_default_dtype(torch.float64)
TEST_DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
def max_abs(tensor):
return torch.max(torch.abs(tensor))
class TestGradient(unittest.TestCase)... | 5,019 | 33.14966 | 96 | py |
steer | steer-master/torchdiffeq/tests/api_tests.py | import unittest
import torch
import torchdiffeq
from problems import construct_problem
eps = 1e-12
torch.set_default_dtype(torch.float64)
TEST_DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
def max_abs(tensor):
return torch.max(torch.abs(tensor))
class TestCollectionState(unittest.Te... | 2,805 | 32.011765 | 114 | py |
steer | steer-master/torchdiffeq/tests/run_all.py | import unittest
from api_tests import *
from gradient_tests import *
from odeint_tests import *
if __name__ == '__main__':
unittest.main()
| 144 | 17.125 | 28 | py |
steer | steer-master/torchdiffeq/tests/odeint_tests.py | import unittest
import torch
import torchdiffeq
import problems
error_tol = 1e-4
torch.set_default_dtype(torch.float64)
TEST_DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
def max_abs(tensor):
return torch.max(torch.abs(tensor))
def rel_error(true, estimate):
return max_abs((true... | 6,526 | 35.875706 | 88 | py |
steer | steer-master/torchdiffeq/tests/problems.py | import math
import numpy as np
import scipy.linalg
import torch
class ConstantODE(torch.nn.Module):
def __init__(self, device):
super(ConstantODE, self).__init__()
self.a = torch.nn.Parameter(torch.tensor(0.2).to(device))
self.b = torch.nn.Parameter(torch.tensor(3.0).to(device))
def ... | 2,533 | 28.126437 | 104 | py |
steer | steer-master/torchdiffeq/tests/DETEST/run.py | import time
import numpy as np
from scipy.stats.mstats import gmean
import torch
from torchdiffeq import odeint
import detest
torch.set_default_tensor_type(torch.DoubleTensor)
class NFEDiffEq:
def __init__(self, diffeq):
self.diffeq = diffeq
self.nfe = 0
def __call__(self, t, y):
se... | 1,843 | 29.733333 | 119 | py |
steer | steer-master/torchdiffeq/tests/DETEST/detest.py | import math
import torch
####################################
# Problem Class A. Single equations.
####################################
def A1():
diffeq = lambda t, y: -y
init = lambda: (torch.tensor(0.), torch.tensor(1.))
solution = lambda t: torch.exp(-t)
return diffeq, init, solution
def A2():
... | 7,740 | 22.107463 | 119 | py |
steer | steer-master/torchdiffeq/torchdiffeq/__init__.py | from ._impl import odeint
from ._impl import odeint_adjoint
from ._impl import odeint_skip_step
from ._impl import odeint_stochastic_end
from ._impl import odeint_stochastic_end_v2
from ._impl import odeint_stochastic_end_v3
from ._impl import odeint_adjoint_skip_step
from ._impl import odeint_adjoint_stochastic_end
fr... | 476 | 38.75 | 53 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_stochastic_end_normal.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 7,776 | 35.511737 | 175 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_adjoint_stochastic_end_normal.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 4,034 | 35.351351 | 181 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 3,113 | 36.518072 | 86 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/adjoint.py | import torch
import torch.nn as nn
from . import odeint
from .misc import _flatten, _flatten_convert_none_to_zeros
class OdeintAdjointMethod(torch.autograd.Function):
@staticmethod
def forward(ctx, *args):
assert len(args) >= 8, 'Internal error: all arguments required.'
y0, func, t, flat_para... | 5,471 | 39.835821 | 111 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_skip_step.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 10,205 | 37.659091 | 132 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_stochastic_end_v2_inference.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 7,970 | 34.744395 | 185 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_adjoint_stochastic_end_v3.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 4,017 | 35.198198 | 184 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_stochastic_end.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 7,165 | 35.01005 | 137 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/adaptive_heun.py | # Based on https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/integrate
import torch
from .misc import (
_scaled_dot_product, _convert_to_tensor, _is_finite, _select_initial_step, _handle_unused_kwargs, _is_iterable,
_optimal_step_size, _compute_error_ratio
)
from .solvers import AdaptiveSt... | 4,839 | 42.214286 | 118 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_stochastic_end_v3.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 7,805 | 35.647887 | 176 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/bosh3.py | import torch
from .misc import (
_scaled_dot_product, _convert_to_tensor, _is_finite, _select_initial_step, _handle_unused_kwargs, _is_iterable,
_optimal_step_size, _compute_error_ratio
)
from .solvers import AdaptiveStepsizeODESolver
from .interp import _interp_fit, _interp_evaluate
from .rk_common import _Run... | 4,552 | 44.989899 | 118 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/misc.py | import warnings
import torch
def _flatten(sequence):
flat = [p.contiguous().view(-1) for p in sequence]
return torch.cat(flat) if len(flat) > 0 else torch.tensor([])
def _flatten_convert_none_to_zeros(sequence, like_sequence):
flat = [
p.contiguous().view(-1) if p is not None else torch.zeros_li... | 6,621 | 32.785714 | 119 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_adjoint_stochastic_end.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 3,574 | 38.722222 | 146 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/interp.py | import torch
from .misc import _convert_to_tensor, _dot_product
def _interp_fit(y0, y1, y_mid, f0, f1, dt):
"""Fit coefficients for 4th order polynomial interpolation.
Args:
y0: function value at the start of the interval.
y1: function value at the end of the interval.
y_mid: function... | 2,501 | 36.909091 | 110 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/tsit5.py | import torch
from .misc import _scaled_dot_product, _convert_to_tensor, _is_finite, _select_initial_step, _handle_unused_kwargs
from .solvers import AdaptiveStepsizeODESolver
from .rk_common import _RungeKuttaState, _ButcherTableau, _runge_kutta_step
# Parameters from Tsitouras (2011).
_TSITOURAS_TABLEAU = _ButcherTab... | 6,777 | 47.414286 | 120 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_adjoint_skip_step.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 3,667 | 38.021277 | 140 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/adams.py | import collections
import torch
from .solvers import AdaptiveStepsizeODESolver
from .misc import (
_handle_unused_kwargs, _select_initial_step, _convert_to_tensor, _scaled_dot_product, _is_iterable,
_optimal_step_size, _compute_error_ratio
)
_MIN_ORDER = 1
_MAX_ORDER = 12
gamma_star = [
1, -1 / 2, -1 / 12... | 7,148 | 39.851429 | 128 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/rk_common.py | # Based on https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/integrate
import collections
from .misc import _scaled_dot_product, _convert_to_tensor
_ButcherTableau = collections.namedtuple('_ButcherTableau', 'alpha beta c_sol c_error')
class _RungeKuttaState(collections.namedtuple('_RungeKuttaS... | 3,673 | 45.506329 | 106 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/__init__.py | from .odeint import odeint
from .odeint_skip_step import odeint_skip_step
from .odeint_stochastic_end import odeint_stochastic_end
from .odeint_stochastic_end_v2 import odeint_stochastic_end_v2
from .odeint_stochastic_end_v3 import odeint_stochastic_end_v3
from .odeint_stochastic_end_normal import odeint_stochastic_end... | 828 | 58.214286 | 86 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_adjoint_stochastic_end_v2.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 4,062 | 35.276786 | 184 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/fixed_grid.py | from .solvers import FixedGridODESolver
from . import rk_common
class Euler(FixedGridODESolver):
def step_func(self, func, t, dt, y):
return tuple(dt * f_ for f_ in func(t, y))
@property
def order(self):
return 1
class Midpoint(FixedGridODESolver):
def step_func(self, func, t, dt,... | 702 | 19.676471 | 72 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/solvers.py | import abc
import torch
from .misc import _assert_increasing, _handle_unused_kwargs
class AdaptiveStepsizeODESolver(object):
__metaclass__ = abc.ABCMeta
def __init__(self, func, y0, atol, rtol, **unused_kwargs):
_handle_unused_kwargs(self, unused_kwargs)
del unused_kwargs
self.func =... | 3,276 | 29.06422 | 89 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/odeint_stochastic_end_v2.py | from .tsit5 import Tsit5Solver
from .dopri5 import Dopri5Solver
from .bosh3 import Bosh3Solver
from .adaptive_heun import AdaptiveHeunSolver
from .fixed_grid import Euler, Midpoint, RK4
from .fixed_adams import AdamsBashforth, AdamsBashforthMoulton
from .adams import VariableCoefficientAdamsBashforth
from .misc import ... | 7,458 | 35.925743 | 175 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/dopri5.py | # Based on https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/integrate
import torch
from .misc import (
_scaled_dot_product, _convert_to_tensor, _is_finite, _select_initial_step, _handle_unused_kwargs, _is_iterable,
_optimal_step_size, _compute_error_ratio
)
from .solvers import AdaptiveSt... | 5,566 | 44.260163 | 118 | py |
steer | steer-master/torchdiffeq/torchdiffeq/_impl/fixed_adams.py | import sys
import collections
from .solvers import FixedGridODESolver
from .misc import _scaled_dot_product, _has_converged
from . import rk_common
_BASHFORTH_COEFFICIENTS = [
[], # order 0
[11],
[3, -1],
[23, -16, 5],
[55, -59, 37, -9],
[1901, -2774, 2616, -1274, 251],
[4277, -7923, 9982,... | 10,784 | 49.872642 | 120 | py |
FragmentVC | FragmentVC-main/convert_batch.py | #!/usr/bin/env python3
"""Convert multiple pairs."""
import warnings
from pathlib import Path
from functools import partial
from multiprocessing import Pool, cpu_count
import yaml
import torch
import numpy as np
import soundfile as sf
from jsonargparse import ArgumentParser, ActionConfigFile
from data import load_wa... | 3,966 | 29.05303 | 87 | py |
FragmentVC | FragmentVC-main/convert.py | #!/usr/bin/env python3
"""Convert using one source utterance and multiple target utterances."""
import warnings
from datetime import datetime
from pathlib import Path
from copy import deepcopy
import torch
import numpy as np
import soundfile as sf
from jsonargparse import ArgumentParser, ActionConfigFile
import sox
... | 4,829 | 32.776224 | 88 | py |
FragmentVC | FragmentVC-main/train.py | #!/usr/bin/env python3
"""Train FragmentVC model."""
import argparse
import datetime
import random
from pathlib import Path
import torch
import torch.nn as nn
from torch.optim import AdamW
from torch.utils.data import DataLoader, random_split
from torch.utils.tensorboard import SummaryWriter
from tqdm import tqdm
fr... | 7,874 | 30.754032 | 88 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.