repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
pyro | tests/distributions/test_sine_bivariate_von_mises.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from scipy.special import binom
from torch import tensor
from torch.distributions import Beta, HalfNormal, VonMises
import pyro
from pyro.distributions import Geometric, constraints
from pyro.distributions.s... | 153 | 5,089 |
pyro | tests/distributions/test_mvn.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions import MultivariateNormal
from tests.common import assert_equal
def random_mvn(loc_shape, cov_shape, dim):
"""
Generate a random MultivariateNormal distribution for test... | 57 | 1,425 |
pyro | tests/distributions/test_spanning_tree.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import os
from collections import Counter
import pytest
import torch
import pyro
from pyro.distributions.spanning_tree import (
NUM_SPANNING_TREES,
SpanningTree,
find_best_tree,
make_complete_graph,... | 232 | 7,701 |
pyro | tests/distributions/test_util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import weakref
import numpy as np
import pytest
import torch
from torch.autograd import grad
import pyro.distributions as dist
from pyro.distributions import constraints
from pyro.distributions.util import (
broadcast_shape,
... | 419 | 13,215 |
pyro | tests/distributions/test_conjugate_update.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_close
@pytest.mark.parametrize("sample_shape", [(), (4,), (3, 2)], ids=str)
@pytest.mark.parametrize("batch_shape", [(), (4,), (3, 2)], ids... | 57 | 2,061 |
pyro | tests/distributions/test_extended.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
from torch.autograd import grad
import pyro.distributions as dist
from pyro.contrib.epidemiology.distributions import set_approx_log_prob_tol
from tests.common import assert_equal
def check_gr... | 97 | 3,462 |
pyro | tests/distributions/test_ordered_logistic.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd.functional import jacobian
from pyro.distributions import Normal, OrderedLogistic
from pyro.distributions.transforms import OrderedTransform
# Tests for the OrderedLogistic distribution
... | 130 | 4,745 |
pyro | tests/distributions/test_hmm.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import operator
from functools import reduce
import opt_einsum
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.distributions.hmm import (
_sequential_gamma_gaussian_tensordot,... | 1,027 | 36,873 |
pyro | tests/distributions/test_kl.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.distributions import kl_divergence, transforms
import pyro.distributions as dist
from pyro.distributions.util import sum_rightmost
from tests.common import assert_close
@pytest.mark.parametr... | 93 | 3,702 |
pyro | tests/distributions/test_projected_normal.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro.distributions as dist
from tests.common import default_dtype
@pytest.mark.parametrize("strength", [0, 1, 10, 100, 1000])
@pytest.mark.parametrize("dim", [2, 3, 4])
@pytest.mark.parametrize("dty... | 25 | 826 |
pyro | tests/distributions/test_rejector.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
from pyro.distributions import Exponential, Gamma
from pyro.distributions.testing.rejection_exponential import RejectionExponential
from pyro.distributions.testing.rejecti... | 178 | 6,748 |
pyro | tests/distributions/test_delta.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase
import numpy as np
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_equal
class TestDelta(TestCase):
def setUp(self):
self.v = torch.tensor([... | 79 | 2,862 |
pyro | tests/distributions/test_von_mises.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import os
import pytest
import torch
from torch import optim
from pyro.distributions import VonMises, VonMises3D
from pyro.distributions.testing.gof import auto_goodness_of_fit
from tests.common import TEST_FAILURE_RA... | 199 | 5,467 |
pyro | tests/distributions/test_improper_uniform.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.distributions import constraints, transform_to
import pyro.distributions as dist
from tests.common import assert_equal
@pytest.mark.parametrize(
"constraint",
[
constraints.real,... | 33 | 966 |
pyro | tests/distributions/test_polya_gamma.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions import TruncatedPolyaGamma
from tests.common import assert_close
@pytest.mark.parametrize("batch_shape", [(), (3,), (2, 1)])
def test_polya_gamma(batch_shape, num_points=20000):
... | 28 | 904 |
pyro | tests/distributions/test_nanmasked.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.infer import SVI, Trace_ELBO
from pyro.infer.autoguide import AutoNormal
from pyro.optim import Adam
from tests.common import assert_close... | 98 | 3,318 |
pyro | tests/distributions/test_one_hot_categorical.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase
import numpy as np
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_equal
class TestOneHotCategorical(TestCase):
"""
Tests methods specific to th... | 116 | 3,921 |
pyro | tests/distributions/test_mask.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch import tensor
from torch.distributions import kl_divergence
from pyro.distributions.torch import Bernoulli, Normal
from pyro.distributions.util import broadcast_shape, scale_and_mask
from test... | 157 | 5,258 |
pyro | tests/distributions/test_sine_skewed.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from math import pi
import pytest
import torch
import pyro
from pyro.distributions import Normal, SineSkewed, Uniform, VonMises, constraints
from pyro.infer import SVI, Trace_ELBO
from pyro.optim import Adam
from tests.common import ... | 108 | 2,967 |
pyro | tests/distributions/test_mixture.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro.distributions as dist
from pyro.distributions.util import broadcast_shape
from pyro.util import torch_isnan
from tests.common import assert_equal
@pytest.mark.parametrize("sample_shape", [(... | 133 | 5,242 |
pyro | tests/distributions/test_mvt.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
from torch.distributions import Gamma, MultivariateNormal, StudentT
from pyro.distributions import MultivariateStudentT
from tests.common import assert_equal
def random_mvt(df_shape, loc_s... | 187 | 5,652 |
pyro | tests/distributions/test_stable_log_prob.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
from scipy.stats import levy_stable
import pyro
import pyro.distributions
import pyro.distributions.stable_log_prob
from pyro.distributions import Stable, constraints
from pyro.infer import S... | 149 | 5,439 |
pyro | tests/distributions/test_ig.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
from pyro.distributions import Gamma, InverseGamma
from tests.common import assert_equal
@pytest.mark.parametrize("concentration", [3.3, 4.0])
@pytest.mark.parametrize("rate", [2.5, 3.0])
... | 34 | 1,192 |
pyro | tests/distributions/test_torch_patch.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_close, requires_cuda
@requires_cuda
def test_dirichlet_grad_cuda():
concentration = torch.ones(3, requires_grad=True)
dist.Diri... | 36 | 1,025 |
pyro | tests/distributions/test_reshape.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions.torch import Bernoulli
from tests.common import assert_equal
def test_sample_shape_order():
shape12 = torch.Size((1, 2))
shape34 = torch.Size((3, 4))
d = Bernoulli(0... | 156 | 5,906 |
pyro | tests/distributions/test_binomial.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro.distributions as dist
from pyro.contrib.epidemiology.distributions import (
set_approx_log_prob_tol,
set_approx_sample_thresh,
)
from tests.common import assert_close
@pytest.mark.param... | 68 | 2,014 |
pyro | tests/distributions/test_pickle.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import inspect
import io
import pickle
import pytest
import torch
import pyro.distributions as dist
from pyro.distributions.torch_distribution import TorchDistributionMixin
from tests.common import xfail_param
# Collect distribu... | 93 | 3,031 |
pyro | tests/distributions/test_omt_mvn.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pyro.distributions import (
AVFMultivariateNormal,
MultivariateNormal,
OMTMultivariateNormal,
)
from tests.common import assert_equal
def analytic_grad(L11=1.0, L22=... | 129 | 4,649 |
pyro | tests/distributions/test_relaxed_straight_through.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
from torch.distributions import constraints
import pyro
import pyro.optim as optim
from pyro.distributions import (
OneHotCategorical,
RelaxedBernoulli,
Relaxe... | 128 | 3,847 |
pyro | tests/distributions/test_constraints.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions import constraints
from pyro.ops.tensor_utils import safe_normalize
@pytest.mark.parametrize("dim", [2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000, 100000])
def test_sphere_check(dim... | 37 | 1,082 |
pyro | tests/distributions/test_lkj.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
from torch.distributions import (
AffineTransform,
Beta,
TransformedDistribution,
biject_to,
transform_to,
)
from pyro.distributions import constraints, transforms
from p... | 150 | 4,821 |
pyro | tests/distributions/test_distributions.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.distributions import TorchDistribution
from pyro.distributions.testing.gof import auto_goodness_of_fit
from pyro.distributions.u... | 445 | 16,165 |
pyro | tests/distributions/dist_fixture.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import numpy as np
import torch
from torch.distributions.utils import logits_to_probs
from pyro.distributions.util import broadcast_shape
SINGLE_TEST_DATUM_IDX = [0]
BATCH_TEST_DATA_IDX = [-1]
class Fixture:
de... | 178 | 6,500 |
pyro | tests/distributions/test_one_one_matching.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_close, assert_equal, xfail_if_not_implemented
BP_ITERS = 50
def _hash(value):
return tuple(value.tolist())... | 157 | 5,643 |
pyro | tests/distributions/test_haar.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions.transforms import HaarTransform
from tests.common import assert_equal
@pytest.mark.parametrize("size", [1, 3, 4, 7, 8, 9])
def test_haar_ortho(size):
haar = HaarTransform()
... | 17 | 399 |
pyro | tests/distributions/test_empirical.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions.empirical import Empirical
from tests.common import assert_close, assert_equal
@pytest.mark.parametrize("size", [[], [1], [2, 3]])
@pytest.mark.parametrize("dtype", [torch.float... | 174 | 7,002 |
pyro | tests/distributions/test_coalescent.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import io
import re
import pytest
import torch
import pyro
from pyro.distributions import CoalescentTimes, CoalescentTimesWithRate
from pyro.distributions.coalescent import (
CoalescentRateLikelihood,
CoalescentTimesConstrain... | 278 | 11,355 |
pyro | tests/distributions/test_one_two_matching.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_close, assert_equal, xfail_if_not_implemented
BP_ITERS = 50
def _hash(value):
return tuple(value.tolist())... | 269 | 9,925 |
pyro | tests/distributions/test_grouped_normal_normal.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
from pyro.distributions import GroupedNormalNormal, Normal
from tests.common import assert_close
def test_grouped_normal_normal(num_groups=3, num_samples=10**5):
prior_scale = torch.rand(num_groups)
... | 45 | 1,565 |
pyro | tests/distributions/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
from math import pi
import numpy as np
import pytest
import scipy.stats as sp
import pyro.distributions as dist
from pyro.distributions.testing.naive_dirichlet import NaiveBeta, NaiveDirichlet
from pyro.distributions.... | 1,082 | 35,808 |
pyro | tests/distributions/testing/test_gof.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.distributions as dist
from pyro.distributions.testing.gof import multinomial_goodness_of_fit
def test_multinomial_goodness_of_fit():
N = 100000
K = 20
logits = torch.randn(K)
probs = (logits... | 21 | 612 |
pyro | tests/distributions/testing/test_special.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import itertools
import numpy as np
import scipy
from pyro.distributions.testing.special import chi2sf
from tests.common import assert_close
def test_chi2sf():
xlist = np.linspace(0, 100, 500)
slist = np.arange(1, 41, 1.5)
... | 18 | 431 |
pyro | tests/perf/test_benchmark.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import cProfile
import os
import re
from collections import namedtuple
import pytest
import torch
import pyro
import pyro.contrib.gp as gp
import pyro.distributions as dist
import pyro.optim as optim
from pyro.dis... | 209 | 6,793 |
pyro | tests/perf/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/perf"):
if "perf" not in item.keywords:
item.add_marker(pytest.mark.stage("perf")... | 14 | 430 |
pyro | tests/poutine/test_counterfactual.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from tests.common import assert_equal, assert_not_equal
def _item(x):
if isinstance(x, torch.Tensor):
x = x.item... | 103 | 3,829 |
pyro | tests/poutine/test_runtime.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.poutine as poutine
from pyro.poutine.runtime import get_mask, get_plates
from tests.common import assert_equal
def test_get_mask():
assert get_mask() is None
with poutine.mask(mask=True)... | 40 | 1,113 |
pyro | tests/poutine/test_trace_struct.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import pytest
from pyro.poutine import Trace
from tests.common import assert_equal
EDGE_SETS = [
# 1
# / \
# 2 3
# / \
# 4 5
# / \
# 6 7
[(1, 2), (1, 3), (3, 4), (3... | 70 | 1,742 |
pyro | tests/poutine/test_properties.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.util import set_rng_seed
from tests.common import assert_equal
EXAMPLE_MODELS = []
EXAMPLE_MODEL_IDS = []
class E... | 147 | 3,965 |
pyro | tests/poutine/test_poutines.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import functools
import io
import logging
import pickle
import warnings
from queue import Queue
from unittest import TestCase
import pytest
import torch
import torch.nn as nn
import pyro
import pyro.distributions as dist
import p... | 1,114 | 39,972 |
pyro | tests/poutine/test_nesting.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
import pyro.poutine.runtime
logger = logging.getLogger(__name__)
def test_nested_reset():
def nested_model():
pyro.sample("... | 32 | 1,068 |
pyro | tests/poutine/test_mapdata.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from tests.common import requires_cuda
logger = logging.getLogger(__name__)
def test_nested_iplate():
m... | 186 | 5,407 |
pyro | tests/poutine/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/poutine"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.stage("un... | 14 | 434 |
pyro | tests/pyroapi/test_pyroapi.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
from pyroapi import pyro_backend
from pyroapi.tests import * # noqa F401
pytestmark = pytest.mark.stage("unit")
@pytest.fixture(params=["pyro", "minipyro"])
def backend(request):
with pyro_backend(request.para... | 15 | 338 |
pyro | tests/pyroapi/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_runtest_call(item):
try:
item.runtest()
except NotImplementedError as e:
pytest.xfail(str(e))
| 12 | 234 |
pyro | tests/infer/test_enum.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import os
import timeit
from collections import defaultdict
from contextlib import ExitStack # python 3
import pytest
import torch
from torch.autograd import grad
from torch.distributions import constra... | 4,103 | 145,511 |
pyro | tests/infer/test_abstract_infer.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.optim as optim
import pyro.poutine as poutine
from pyro.infer import SVI, Trace_ELBO
from pyro.infer.autoguide import AutoLaplaceApproximation
fr... | 96 | 2,732 |
pyro | tests/infer/test_conjugate_gradients.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pyro
from pyro.infer.tracegraph_elbo import TraceGraph_ELBO
from tests.common import assert_equal
from tests.integration_tests.test_conjugate_gaussian_models import GaussianChain
class ConjugateChainGradientTests(GaussianC... | 44 | 1,616 |
pyro | tests/infer/test_util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer.importance import psis_diagnostic
from pyro.infer.util import MultiFrameTensor
from tests.common ... | 85 | 2,707 |
pyro | tests/infer/test_smcfilter.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer import SMCFilter
from pyro.infer.smcfilter import _systematic_sample
from tests.common import assert_close
@... | 273 | 8,196 |
pyro | tests/infer/test_csis.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import torch.nn as nn
import pyro
import pyro.distributions as dist
import pyro.infer
import pyro.optim
from tests.common import assert_equal, assert_not_equal
def model(observations={"y1": 0, "y2": 0}... | 70 | 2,468 |
pyro | tests/infer/test_predictive.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.optim as optim
import pyro.poutine as poutine
from pyro.infer import SVI, MHResampler, Predictive, Trace_ELBO, WeighedPredictive
... | 311 | 12,494 |
pyro | tests/infer/test_compute_downstream_costs.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
from collections import defaultdict
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer.tracegraph_elbo import TrackNonReparam, _compute_downstream_c... | 788 | 29,962 |
pyro | tests/infer/test_inference.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
from unittest import TestCase
import pytest
import torch
from torch.distributions import constraints
import pyro
import pyro.contrib.gp.kernels as kernels
import pyro.distributions as dist
import pyro.o... | 1,008 | 36,696 |
pyro | tests/infer/test_inspect.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.distributions.testing.fakes import NonreparameterizedNormal
from pyro.infer.inspect import _deep_merge, get_dependencies, get_model_relations
@pytest... | 559 | 16,351 |
pyro | tests/infer/test_autoguide.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import functools
import io
import warnings
import numpy as np
import pytest
import torch
from torch import nn
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.poutine as poutin... | 1,620 | 51,698 |
pyro | tests/infer/test_valid_models.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import warnings
from collections import defaultdict
import pytest
import torch
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.dist... | 2,783 | 93,251 |
pyro | tests/infer/test_tmc.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import pytest
import torch
from torch.autograd import grad
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.distribution... | 299 | 10,256 |
pyro | tests/infer/test_initialization.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.autoguide.initialization import (
InitMessenger,
init_to_generated,
init_to_value,
)
def test_init_to_generated():
def model():
x = p... | 41 | 1,066 |
pyro | tests/infer/test_resampler.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import functools
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.resampler import Resampler
from tests.common import assert_close
@pytest.mark.parametrize("stable", [False, True])
def test_r... | 44 | 1,321 |
pyro | tests/infer/test_gradient.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import numpy as np
import pytest
import torch
import torch.optim
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.distributions.test... | 432 | 15,384 |
pyro | tests/infer/test_sampling.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase
import pytest
import torch
import pyro
import pyro.infer
from pyro.distributions import Bernoulli, Normal
from pyro.infer import EmpiricalMarginal
from tests.common import assert_equal
class HMMSam... | 104 | 3,216 |
pyro | tests/infer/test_elbo_mapdata.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.optim as optim
from pyro.infer import SVI, TraceGraph_ELBO
from tests.common import assert_equal
logger = logging.getLogger(__na... | 130 | 4,196 |
pyro | tests/infer/test_multi_sample_elbos.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.infer import RenyiELBO
from tests.common import assert_close
def check_elbo(model, guide, Elbo):
elbo = Elbo(num_particles=2, vectorize_particles... | 59 | 1,638 |
pyro | tests/infer/test_svgd.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.infer import SVGD, IMQSteinKernel, RBFSteinKernel
from pyro.infer.autoguide.utils import _product
from pyro.optim import Adam
from tests.common imp... | 150 | 5,251 |
pyro | tests/infer/test_discrete.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import warnings
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer import TraceEnum_ELBO
from pyro.infer.di... | 424 | 14,353 |
pyro | tests/infer/test_jit.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import warnings
import pytest
import torch
from torch.autograd import grad
from torch.distributions import constraints, kl_divergence
import pyro
import pyro.distributions as dist
import pyro.ops.jit
import pyro.po... | 614 | 19,363 |
pyro | tests/infer/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/infer"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.stage("unit... | 14 | 432 |
pyro | tests/infer/reparam/test_conjugate.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer import Predictive, Trace_ELBO
from pyro.infer.autoguide import AutoDiagonalNormal
from pyro.infer.mcmc.api import ... | 253 | 9,154 |
pyro | tests/infer/reparam/test_neutra.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro import optim
from pyro.distributions.transforms import ComposeTransform
from pyro.infer import MCMC, NUTS, SVI, Trace_ELBO
from pyro.infer.autoguid... | 97 | 3,101 |
pyro | tests/infer/reparam/test_transform.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.distributions.transforms import AffineTransform, ExpTransform
from pyro.infer.reparam import TransformReparam
from t... | 83 | 2,709 |
pyro | tests/infer/reparam/test_stable.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from scipy.stats import ks_2samp
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.distributions.torch_distribution import MaskedDistributio... | 168 | 6,419 |
pyro | tests/infer/reparam/test_strategies.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer import SVI, Predictive, Trace_ELBO
from pyro.infer.autoguide import AutoNormal
from pyro.infer.reparam import AutoRepara... | 342 | 10,119 |
pyro | tests/infer/reparam/util.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import warnings
import pytest
from pyro import poutine
from pyro.infer.autoguide.initialization import InitMessenger, init_to_value
from pyro.infer.reparam.reparam import Reparam
from tests.common import assert_close
def check_init... | 35 | 1,193 |
pyro | tests/infer/reparam/test_unit_jacobian.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.distributions.transforms import Permute
from pyro.infer.reparam import UnitJacobianReparam
fro... | 72 | 2,597 |
pyro | tests/infer/reparam/test_structured.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro import optim
from pyro.infer import MCMC, NUTS, SVI, JitTrace_ELBO, Trace_ELBO
from pyro.infer.autoguide import AutoStructured
from pyro.infer.reparam ... | 66 | 2,029 |
pyro | tests/infer/reparam/test_loc_scale.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.distributions.util import is_identically_one
from pyro.infer.autoguide.initialization impo... | 110 | 4,077 |
pyro | tests/infer/reparam/test_hmm.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import (
LinearHMMReparam,
StableReparam,
StudentTReparam,
SymmetricStableReparam,
)
from tests.... | 298 | 12,130 |
pyro | tests/infer/reparam/test_projected_normal.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import ProjectedNormalReparam
from tests.common import assert_close
from .util ... | 62 | 2,118 |
pyro | tests/infer/reparam/test_studentt.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from scipy.stats import ks_2samp
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import StudentTReparam
from tests.common import... | 82 | 3,021 |
pyro | tests/infer/reparam/test_split.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.autoguide.initialization import InitMessenger, init_to_median
from pyro.infer.reparam im... | 217 | 7,183 |
pyro | tests/infer/reparam/test_discrete_cosine.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import DiscreteCosineReparam
from tests.common import assert_close
from .util i... | 137 | 4,030 |
pyro | tests/infer/reparam/test_softmax.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import GumbelSoftmaxReparam
from tests.common import assert_close
from .uti... | 68 | 2,305 |
pyro | tests/infer/reparam/test_haar.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.distributions.transforms.haar import HaarTransform
from pyro.infer.autoguide.initialization im... | 189 | 6,392 |
pyro | tests/infer/autoguide/test_mean_field_entropy.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import scipy.special as sc
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.autoguide.utils import mean_field_entropy
from tests.common import assert_equal
def mean_field_guide(batch_tenso... | 39 | 1,064 |
pyro | tests/infer/autoguide/test_gaussian.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import OrderedDict, namedtuple
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer import SVI, JitTrace_ELBO, Predictive, Trace_ELBO
from pyro.infer... | 875 | 29,698 |
pyro | tests/infer/autoguide/test_inference.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
from functools import partial
import numpy as np
import pytest
import torch
from torch.distributions import biject_to, constraints
import pyro
import pyro.distributions as dist
import pyro.optim as optim
from pyro.... | 256 | 8,100 |
pyro | tests/infer/autoguide/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/infer/autoguide"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.s... | 14 | 442 |
pyro | tests/infer/mcmc/test_mcmc_api.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import os
from functools import partial
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.mcmc import HMC, NUTS
from pyro.infer.mcmc.api import MCMC, StreamingMCMC, ... | 414 | 12,719 |
pyro | tests/infer/mcmc/test_rwkernel.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.mcmc.api import MCMC
from pyro.infer.mcmc.rwkernel import RandomWalkKernel
from tests.common import assert_equal
def test_beta_bernoulli():
alpha = t... | 41 | 1,308 |
pyro | tests/infer/mcmc/test_hmc.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import os
from collections import namedtuple
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.mcmc import NUTS
from pyro.infer.mcmc.api import MCMC
from pyro.infer.mcmc.hmc i... | 363 | 11,825 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.