python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
import torch import numpy as np from torch.nn import Parameter from halp.layers.pool_layer import BitCenterMaxPool2D, BitCenterAvgPool2D from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from unittest import TestCase from halp.utils.utils import set_seed from halp.utils.test_utils imp...
halp-master
halp/layers/pool_layer_test.py
import torch import numpy as np import torch.nn.functional as F from torch.nn import Parameter from halp.layers.ele_mult import BitCenterEleMult, bit_center_ele_mult from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from unittest import TestCase from halp.layers.bit_center_layer_test ...
halp-master
halp/layers/ele_mult_test.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from torch.nn import Parameter import numpy as np from halp.layers.linear_layer import BitCenterLinear, bit_center_linear from torch.autograd import gradcheck from halp.utils.utils import void_cast_func, single_to_hal...
halp-master
halp/layers/bit_center_layer_test.py
import torch import torch.nn as nn from math import floor from torch.nn import Conv2d import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Function from torch.autograd import Variable import numpy as np from halp.utils.utils import void_cast_func, single_to_half_det, singl...
halp-master
halp/layers/conv_layer.py
import torch import torch.nn as nn from torch.nn import Tanh import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Function import numpy as np from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from halp.layers.bit_center_layer import BitCe...
halp-master
halp/layers/sigmoid_layer.py
import torch import torch.nn as nn from torch.nn import Tanh import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Function import numpy as np from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from halp.layers.bit_center_layer import BitCe...
halp-master
halp/layers/tanh_layer.py
import torch import numpy as np from torch.nn import Parameter from halp.layers.relu_layer import BitCenterReLU, bit_center_relu from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from unittest import TestCase from halp.utils.utils import set_seed from halp.utils.test_utils import Halp...
halp-master
halp/layers/relu_layer_test.py
import torch import numpy as np import copy, logging from torch.autograd import Variable from torch.optim.optimizer import required, Optimizer from torch.optim import SGD from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from halp.optim.bit_center_sgd import BitCenterOptim import logg...
halp-master
halp/optim/bit_center_svrg.py
from torch.optim.optimizer import Optimizer, required import torch from torch.autograd import Variable import copy, logging class SVRG(torch.optim.SGD): """Implements stochastic variance reduction gradient descent. Args: params (iterable): iterable of parameters to optimize lr (float): learnin...
halp-master
halp/optim/svrg.py
halp-master
halp/optim/__init__.py
import torch import torch.nn as nn import numpy as np from halp.utils.test_utils import HalpTest from halp.optim.bit_center_sgd import BitCenterSGD from halp.optim.bit_center_svrg import BitCenterSVRG from unittest import TestCase from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from...
halp-master
halp/optim/bit_center_optim_test.py
import torch import numpy as np import copy, logging from torch.autograd import Variable from torch.optim.optimizer import required, Optimizer from torch.optim import SGD from halp.utils.utils import void_cast_func, single_to_half_det, single_to_half_stoc from halp.utils.utils import get_recur_attr import logging impor...
halp-master
halp/optim/bit_center_sgd.py
import torch import torch.nn as nn from torch.autograd import Variable import numpy as np from torch.autograd import gradcheck from halp.layers.bit_center_layer import BitCenterModule, BitCenterModuleList from halp.layers.linear_layer import BitCenterLinear from halp.utils.utils import void_cast_func, single_to_half_de...
halp-master
halp/utils/test_utils.py
import torch import numpy as np import logging import sys import math from halp.optim.bit_center_sgd import BitCenterOptim, BitCenterSGD from halp.optim.bit_center_svrg import BitCenterSVRG from halp.optim.svrg import SVRG from halp.utils.utils import get_recur_attr logging.basicConfig(stream=sys.stdout, level=logging....
halp-master
halp/utils/train_utils.py
halp-master
halp/utils/__init__.py
import nltk from nltk.stem import PorterStemmer import numpy as np import sys, os import torch from halp.utils.utils import set_seed from halp.utils.utils import DOUBLE_PREC_DEBUG_EPOCH_LEN, LP_DEBUG_EPOCH_LEN from torch.utils.data.dataset import Dataset import _pickle as cp import logging logging.basicConfig(stream=sy...
halp-master
halp/utils/postag_data_utils.py
import gzip import os from os import path import numpy as np import torch import sys if sys.version_info.major < 3: import urllib else: import urllib.request as request from halp.utils.utils import LP_DEBUG_EPOCH_LEN, DOUBLE_PREC_DEBUG_EPOCH_LEN DATASET_DIR = 'datasets/' MNIST_FILES = ["train-images-idx3-u...
halp-master
halp/utils/mnist_data_utils.py
import torch import numpy as np import ctypes from unittest import TestCase import logging import sys logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) logger = logging.getLogger('') # DOUBLE_PREC_DEBUG = False DOUBLE_PREC_DEBUG_EPOCH_LEN = 3 # LP_DEBUG = False LP_DEBUG_EPOCH_LEN = 3 def single_to_half_de...
halp-master
halp/utils/utils.py
import torch import torchvision import torchvision.transforms as transforms import numpy as np from halp.utils.utils import LP_DEBUG_EPOCH_LEN, DOUBLE_PREC_DEBUG_EPOCH_LEN import sys import logging logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) logger = logging.getLogger('') def get_cifar10_data_loader(b...
halp-master
halp/utils/cifar_data_utils.py
import torch import numpy as np from torch.autograd import Variable # from halp.utils.test_utils import assert_model_grad_equal from halp.utils.utils import get_recur_attr from halp.utils.utils import single_to_half_det, single_to_half_stoc, void_cast_func from halp.utils.utils import copy_model_weights, set_seed from ...
halp-master
halp/models/model_test.py
halp-master
halp/models/__init__.py
import torch import numpy as np from torch.autograd import Variable from halp.utils.utils import single_to_half_det, single_to_half_stoc, void_cast_func from halp.utils.utils import copy_model_weights, set_seed from unittest import TestCase from halp.utils.test_utils import HalpTest from halp.models.lenet import LeNet_...
halp-master
halp/models/lenet_test.py
import torch import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from halp.utils.utils import single_to_half_det, single_to_half_stoc, copy_layer_weights from halp.utils.utils import void_cast_func, get_recur_attr from halp.layers.bit_center_layer import BitCent...
halp-master
halp/models/lenet.py
import torch import numpy as np from torch.autograd import Variable import halp.utils.utils from halp.utils.utils import single_to_half_det, single_to_half_stoc from halp.models.logistic_regression import LogisticRegression from unittest import TestCase class LeNetTest(TestCase): def test_logistic_regression_gra...
halp-master
halp/models/logistic_regression_test.py
import torch import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from halp.utils.utils import single_to_half_det, single_to_half_stoc from halp.utils.utils import copy_layer_weights, copy_module_weights from halp.utils.utils import void_cast_func, get_recur_attr ...
halp-master
halp/models/resnet.py
import torch import numpy as np from torch.autograd import Variable from halp.utils.utils import single_to_half_det, single_to_half_stoc, void_cast_func from halp.layers.bit_center_layer import BitCenterModule from halp.layers.linear_layer import BitCenterLinear from halp.layers.cross_entropy import BitCenterCrossEntro...
halp-master
halp/models/logistic_regression.py
import torch import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Variable from halp.utils.utils import single_to_half_det, single_to_half_stoc from halp.utils.utils import copy_layer_weights, copy_module_weights from halp.utils.uti...
halp-master
halp/models/lstm.py
import torch import numpy as np from torch.autograd import Variable # from halp.utils.test_utils import assert_model_grad_equal from halp.utils.utils import single_to_half_det, single_to_half_stoc, void_cast_func from halp.utils.utils import copy_model_weights, set_seed, get_recur_attr from unittest import TestCase fro...
halp-master
halp/models/lstm_test.py
import torch import numpy as np from torch.autograd import Variable # from halp.utils.test_utils import assert_model_grad_equal from halp.utils.utils import single_to_half_det, single_to_half_stoc, void_cast_func from halp.utils.utils import copy_model_weights, set_seed, get_recur_attr from unittest import TestCase fro...
halp-master
halp/models/resnet_test.py
import copy import argparse import math import numpy as np import torch torch.backends.cudnn.deterministic=True import torch.nn as nn import torch.utils.data from torch.optim import SGD import halp from halp.optim.bit_center_sgd import BitCenterSGD from halp.optim.bit_center_svrg import BitCenterSVRG from halp.optim.sv...
halp-master
halp/exp_script/run_models.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import platform import re import sys from glob import glob from pybind11.setup_helpers import build_ext, Pybind11Extension from s...
beanmachine-main
setup.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # ...
beanmachine-main
website/sphinx/conf.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import re import shutil import uuid import warnings from pathlib import Path from typing import Any, Dict, List, Tuple, Union i...
beanmachine-main
website/scripts/convert_ipynb_to_mdx.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch.distributions as dist from torch import tensor class ToplevelSmokeTest(unittest...
beanmachine-main
tests/ppl/smoke_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import pytest import torch.distributions as dist @pytest.fixture(autouse=True) def fix_random_seed(): """...
beanmachine-main
tests/ppl/conftest.py
beanmachine-main
tests/ppl/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import pytest import torch from beanmachine.ppl.experimental.torch_jit_backend import get_backend, TorchJITBac...
beanmachine-main
tests/ppl/experimental/torch_jit_backend_test.py
beanmachine-main
tests/ppl/experimental/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.split_rule import ( CompositeRules, Dimen...
beanmachine-main
tests/ppl/experimental/bart/bart_split_rule_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.scalar_samplers import ( NoiseStandardDeviatio...
beanmachine-main
tests/ppl/experimental/bart/bart_scalar_sampler_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.exceptions import ( GrowError, PruneErro...
beanmachine-main
tests/ppl/experimental/bart/bart_tree_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from copy import deepcopy import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.exceptions import ( ...
beanmachine-main
tests/ppl/experimental/bart/bart_node_test.py
beanmachine-main
tests/ppl/experimental/bart/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.exceptions import ( PruneError, ) from beanm...
beanmachine-main
tests/ppl/experimental/bart/bart_tree_proposer_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.bart_model import ( LeafMean, ) from beanmach...
beanmachine-main
tests/ppl/experimental/bart/xbart_grow_from_root_proposer_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from beanmachine.ppl.experimental.causal_inference.models.bart.bart_model import ( BART, XBART, ) @pyt...
beanmachine-main
tests/ppl/experimental/bart/bart_model_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.experimental.gp import ( ...
beanmachine-main
tests/ppl/experimental/gp/models_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import unittest import beanmachine.ppl as bm import gpytorch import torch from beanmachine.ppl.experimental.gp import ( bm_...
beanmachine-main
tests/ppl/experimental/gp/inference_test.py
beanmachine-main
tests/ppl/experimental/gp/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch.distributions as dist from beanmachine.ppl.world.utils import get_default_transforms, initialize_value def test...
beanmachine-main
tests/ppl/world/utils_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.world import World class SampleModel: ...
beanmachine-main
tests/ppl/world/world_test.py
beanmachine-main
tests/ppl/world/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch import torch.distributions as dist from beanmachine.ppl.world.initialize_fn import init_from_prior, init_to_unifo...
beanmachine-main
tests/ppl/world/initialize_fn_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest import torch import torch.distributions as dist from beanmachine.ppl.world.variable import Variable def test_log_prob(): ...
beanmachine-main
tests/ppl/world/variable_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from beanmachine.ppl.utils import tensorops class TensorOpsTest(unittest.TestCase): def test_gradients(s...
beanmachine-main
tests/ppl/utils/tensorops_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.utils.set_of_tensors import SetOfTensors from torch import tensor class SetOfTensorsTest(unittest.Te...
beanmachine-main
tests/ppl/utils/set_of_tensors_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.utils.multidictionary import MultiDictionary class MultiDictionaryTest(unittest.TestCase): def t...
beanmachine-main
tests/ppl/utils/multidictionary_test.py
beanmachine-main
tests/ppl/utils/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for Graph from graph.py""" import unittest from beanmachine.ppl.utils.graph import Graph class SimpleNode(object): name: str...
beanmachine-main
tests/ppl/utils/graph_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for item_counter.py""" import unittest from beanmachine.ppl.utils.item_counter import ItemCounter class ItemCounterTest(unittest...
beanmachine-main
tests/ppl/utils/item_counter_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for print_tree from treeprinter.py""" import unittest from beanmachine.ppl.utils.treeprinter import print_tree class TreePrinter...
beanmachine-main
tests/ppl/utils/treeprinter_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for memoize.py""" import unittest from beanmachine.ppl.utils.memoize import memoize count1 = 0 def fib(n): global count1 ...
beanmachine-main
tests/ppl/utils/memoize_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for partition functions from equivalence.py""" import unittest from typing import Any, Iterable from beanmachine.ppl.utils.equival...
beanmachine-main
tests/ppl/utils/equivalence_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for print_graph from dotbuilder.py""" import unittest from typing import Any, Dict from beanmachine.ppl.utils.dotbuilder import Do...
beanmachine-main
tests/ppl/utils/dotbuilder_test.py
beanmachine-main
tests/ppl/testlib/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for hypothesis_testing.py""" import unittest from beanmachine.ppl.testlib.hypothesis_testing import ( inverse_chi2_cdf, in...
beanmachine-main
tests/ppl/testlib/hypothesis_testing_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pickle import unittest import warnings import beanmachine.ppl as bm import torch import torch.distributions as dist import torch.uti...
beanmachine-main
tests/ppl/model/rv_identifier_test.py
beanmachine-main
tests/ppl/model/__init__.py
beanmachine-main
tests/ppl/diagnostics/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Dict import beanmachine.ppl as bm import beanmachine.ppl.diagnostics.common_statistics as common_statist...
beanmachine-main
tests/ppl/diagnostics/diagnostics_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_newtonian_monte_carlo_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pickle import unittest import beanmachine.ppl as bm import numpy as np import torch import torch.distributions as dist import xarray...
beanmachine-main
tests/ppl/inference/monte_carlo_samples_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_uniform_mh_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_random_walk_adaptive_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import torch import torch.distributions as dist class SampleModel: @bm.random_variable def foo(self):...
beanmachine-main
tests/ppl/inference/single_site_ancestral_mh_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_no_u_turn_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import torch import torch.distributions as dist @bm.random_variable def foo(): return dist.Normal(0.0, 1....
beanmachine-main
tests/ppl/inference/utils_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings import beanmachine.ppl as bm import pytest import torch import torch.distributions as dist class SampleModel: @bm.ran...
beanmachine-main
tests/ppl/inference/nnc_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import sys import beanmachine.ppl as bm import pytest import torch import torch.distributions as dist from beanmachine.ppl.infe...
beanmachine-main
tests/ppl/inference/inference_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist class SingleSiteUniformMetropolisHastingsTes...
beanmachine-main
tests/ppl/inference/single_site_uniform_mh_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools from typing import Optional import beanmachine.ppl as bm import numpy import pytest import scipy.stats import torch import...
beanmachine-main
tests/ppl/inference/vi_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import beanmachine.ppl as bm import pytest import torch import torch.distributions as dist from beanmachine.ppl...
beanmachine-main
tests/ppl/inference/vi_gpu_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.examples.conjugate_models...
beanmachine-main
tests/ppl/inference/single_site_random_walk_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist class IntegrationTest(unittest.TestCase): ...
beanmachine-main
tests/ppl/inference/inference_integration_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import Counter from unittest.mock import patch import beanmachine.ppl as bm import pytest import torch import torch.distri...
beanmachine-main
tests/ppl/inference/compositional_infer_test.py
beanmachine-main
tests/ppl/inference/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import torch import torch.distributions as dist class SampleModel: @bm.random_variable def foo(self):...
beanmachine-main
tests/ppl/inference/sampler_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_random_walk_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings import beanmachine.ppl as bm import pytest import torch import torch.distributions as dist @bm.random_variable def f(): ...
beanmachine-main
tests/ppl/inference/inference_error_reporting_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist class PredictiveTest(unittest.TestCase): ...
beanmachine-main
tests/ppl/inference/predictive_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from sys import float_info import torch.distributions as dist from beanmachine.ppl.testlib.hypothesis_testing import ( ...
beanmachine-main
tests/ppl/inference/hypothesis_testing_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.inference import SingleS...
beanmachine-main
tests/ppl/inference/single_site_newtonian_monte_carlo_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_hamiltonian_monte_carlo_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.testlib.abstract_conjugate import AbstractConjugateTests class SingleSi...
beanmachine-main
tests/ppl/inference/single_site_ancestral_mh_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.inference.compositional_infer import CompositionalInference from beanmachine.ppl.testlib.abstract_conj...
beanmachine-main
tests/ppl/inference/compositional_infer_conjugate_test_nightly.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import pytest import torch import torch.distributions as dist from beanmachine.ppl.inference.proposer.hmc_propo...
beanmachine-main
tests/ppl/inference/proposer/hmc_proposer_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit test for NormalEig class""" import unittest import torch from beanmachine.ppl.inference.proposer.normal_eig import NormalEig from t...
beanmachine-main
tests/ppl/inference/proposer/normal_eig_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from beanmachine.ppl.inference.proposer.utils import DictToVecConverter def test_dict_to_vec_conversion(): d = {"a": torc...
beanmachine-main
tests/ppl/inference/proposer/utils_test.py
beanmachine-main
tests/ppl/inference/proposer/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import beanmachine.ppl as bm import pytest import torch import torch.distributions as dist from beanmachine.ppl.inference.proposer.nuts_prop...
beanmachine-main
tests/ppl/inference/proposer/nuts_proposer_test.py