python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
# 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.
"""Parameterized test to compare samples from original
and conjugate prior transformed models"""
import random
import pytest
import sci... | beanmachine-main | tests/ppl/compiler/testlib/fix_beta_conjugacy_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.graph as bmg
import numpy as np
def tidy(s: str) -> str:
return "\n".join(c.strip() fo... | beanmachine-main | tests/graph/operator_test.py |
beanmachine-main | tests/graph/__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 math
import unittest
import numpy as np
from beanmachine import graph
class TestNMC(unittest.TestCase):
# see https://www.jsta... | beanmachine-main | tests/graph/nmc_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 numpy as np
from beanmachine import graph
class TestBayesNet(unittest.TestCase):
def test_simple_dep(self):
... | beanmachine-main | tests/graph/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.
import math
import unittest
import numpy as np
from beanmachine import graph
class TestCAVI(unittest.TestCase):
def test_interface(se... | beanmachine-main | tests/graph/cavi_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.
__version__ = "0.2.0"
| beanmachine-main | src/beanmachine/__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.
"""
The file contains MiniBM, a minimal implementation of Bean Machine PPL with a Metropolis
Hastings implementation and a coin flipping mod... | beanmachine-main | src/beanmachine/minibm.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 torch.distributions import Distribution
from . import experimental
from .diagnostics import Diagnostics
from .diagnostics.common_stati... | beanmachine-main | src/beanmachine/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.
| beanmachine-main | src/beanmachine/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 warnings
from enum import Enum
from typing import Callable
from beanmachine.ppl.inference.proposer.nnc import nnc_jit
class Torch... | beanmachine-main | src/beanmachine/ppl/experimental/torch_jit_backend.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 gpytorch as gpt
import torch
from botorch.models.gpytorch import GPyTorchModel
from botorch.posteriors.gpytorch import GPyTorchPoster... | beanmachine-main | src/beanmachine/ppl/experimental/gp/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.
from typing import Dict
import beanmachine.ppl as bm
import gpytorch
from beanmachine.ppl import RVIdentifier
from beanmachine.ppl.world im... | beanmachine-main | src/beanmachine/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.
| beanmachine-main | src/beanmachine/ppl/experimental/causal_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.
| beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/__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.
from typing import List, Optional, Union
import torch
from beanmachine.ppl.experimental.causal_inference.models.bart.exceptions import (
... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/tree.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 abc import ABC
from dataclasses import dataclass
from typing import Union
from beanmachine.ppl.experimental.causal_inference.models.ba... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/mutation.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 abc import ABCMeta, abstractmethod
import torch
from .tree import Tree
class TreeProposer(metaclass=ABCMeta):
@abstractmethod
... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/tree_proposer.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.
| beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/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 math
from collections import Counter
from math import log
from typing import cast, List, NamedTuple, Optional, Tuple
import torch
f... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/grow_from_root_tree_proposer.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 enum
from dataclasses import dataclass
from typing import List, Optional
import torch
class Operator(enum.Enum):
le = "less th... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/split_rule.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.
class TreeStructureError(Exception):
"""Base class for errors related to tree structure"""
pass
class PruneError(TreeStructureEr... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/exceptions.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.
# For now supports only ordered numeric variables
from __future__ import annotations
import math
from copy import deepcopy
from typing imp... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/bart_model.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
from typing import Optional
import torch
from beanmachine.ppl.experimental.causal_inference.models.bart.node import LeafNode
f... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/scalar_samplers.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 List, Optional, overload, Tuple, Union
import torch
from beanmachine.ppl.experimental.causal_inference.models.bart.exce... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/node.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 enum
import math
from typing import Union
import torch
from beanmachine.ppl.experimental.causal_inference.models.bart.exceptions im... | beanmachine-main | src/beanmachine/ppl/experimental/causal_inference/models/bart/grow_prune_tree_proposer.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 __future__ import annotations
import dataclasses
from typing import (
Collection,
Dict,
Iterable,
Iterator,
List,
... | beanmachine-main | src/beanmachine/ppl/world/world.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.
# pyre-ignore-all-errors[16, 20]
from typing import Callable
import torch
import torch.distributions as dist
InitializeFn = Callable[[dis... | beanmachine-main | src/beanmachine/ppl/world/initialize_fn.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 beanmachine.ppl.world.base_world import get_world_context
from beanmachine.ppl.world.initialize_fn import (
init_from_prior,
in... | beanmachine-main | src/beanmachine/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.
from __future__ import annotations
import dataclasses
from typing import Set
import torch
import torch.distributions as dist
from beanmach... | beanmachine-main | src/beanmachine/ppl/world/variable.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.abc import Iterable
from typing import Iterable as IterableType, overload, Type, Union
import torch
import torch.distribut... | beanmachine-main | src/beanmachine/ppl/world/utils.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 __future__ import annotations
from abc import ABCMeta, abstractmethod
from typing import Optional
import torch
from beanmachine.ppl.m... | beanmachine-main | src/beanmachine/ppl/world/base_world.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 inspect
from functools import wraps
from typing import Any, Callable, Dict, Tuple
from beanmachine.ppl.utils.item_counter import Ite... | beanmachine-main | src/beanmachine/ppl/utils/memoize.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.
"""A helper class to give unique names to a set of objects."""
from typing import Any, Callable, Dict, Optional
def make_namer(
namer:... | beanmachine-main | src/beanmachine/ppl/utils/unique_name.py |
#!/usr/bin/env python3
# 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.
"""A mutable graph builder"""
from hashlib import md5
from typing import Callable, Dict, Generic, List, Optional, Typ... | beanmachine-main | src/beanmachine/ppl/utils/graph.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 beanmachine.ppl.utils.dotbuilder import DotBuilder, print_graph
from beanmachine.ppl.utils.equivalence import partition_by_kernel, part... | beanmachine-main | src/beanmachine/ppl/utils/__init__.py |
#!/usr/bin/env python3
# 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.
"""A builder for the graphviz DOT language"""
import json
import re
from typing import Any, Callable, Dict, List, Opt... | beanmachine-main | src/beanmachine/ppl/utils/dotbuilder.py |
#!/usr/bin/env python3
# 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 re
def _first_word(s: str) -> str:
r = re.search("\\w+", s)
return r.group(0) if r else ""
_always... | beanmachine-main | src/beanmachine/ppl/utils/a_or_an.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.
"""Defines print_tree, a helper function to render Python objects as trees."""
from typing import Any, Callable, List
def _is_named_tuple_... | beanmachine-main | src/beanmachine/ppl/utils/treeprinter.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.
# This is just a little wrapper class around a dictionary for quickly
# and easily counting how many of each item you've got.
from typing i... | beanmachine-main | src/beanmachine/ppl/utils/item_counter.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 Tuple
import torch
import torch.autograd
from torch._vmap_internals import _vmap as vmap
def gradients(
outputs: t... | beanmachine-main | src/beanmachine/ppl/utils/tensorops.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.
"""Defines partition, a helper function to partition a set into
equivalence classes by an equivalence relation."""
from collections import d... | beanmachine-main | src/beanmachine/ppl/utils/equivalence.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 collections
from typing import Set, Tuple
from beanmachine.ppl.utils.memoize import tensor_to_tuple
from torch import Tensor, tensor... | beanmachine-main | src/beanmachine/ppl/utils/set_of_tensors.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 Any, Dict, Set
class MultiDictionary:
"""A simple append-only multidictionary; values are deduplicated
and must... | beanmachine-main | src/beanmachine/ppl/utils/multidictionary.py |
beanmachine-main | src/beanmachine/ppl/examples/__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.distributions as dist
from torch import Tensor
class BetaBinomialModel:
"""This Bean Machine... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/beta_binomial.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 beanmachine.ppl.examples.conjugate_models.beta_binomial import BetaBinomialModel
from beanmachine.ppl.examples.conjugate_models.categor... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/__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.distributions as dist
from torch import Tensor
class CategoricalDirichletModel:
def __init__... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/categorical_dirichlet.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.distributions as dist
from torch import Tensor
class NormalNormalModel:
def __init__(self, m... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/normal_normal.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.distributions as dist
from torch import Tensor
class BetaBernoulliModel:
def __init__(self, ... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/beta_bernoulli.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 torch import Tensor
class GammaNormalModel:
def __in... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/gamma_normal.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.distributions as dist
from torch import Tensor
class GammaGammaModel:
def __init__(self, sha... | beanmachine-main | src/beanmachine/ppl/examples/conjugate_models/gamma_gamma.py |
beanmachine-main | src/beanmachine/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.
from abc import ABCMeta, abstractmethod
from typing import Dict, List, Optional, Tuple
import numpy as np
import scipy.stats
import torch
f... | beanmachine-main | src/beanmachine/ppl/testlib/abstract_conjugate.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 numpy as np
import scipy.stats as stats
import torch
# This module defines hypothesis tests for equal means and equal variance
# H... | beanmachine-main | src/beanmachine/ppl/testlib/hypothesis_testing.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 functools import wraps
from typing import Callable, Union
import torch
import torch.distributions as dist
from beanmachine.ppl.inferen... | beanmachine-main | src/beanmachine/ppl/model/statistical_model.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 beanmachine.ppl.model.rv_identifier import RVIdentifier
from beanmachine.ppl.model.statistical_model import (
functional,
param... | beanmachine-main | src/beanmachine/ppl/model/__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 warnings
from dataclasses import dataclass
from typing import Any, Callable, Tuple
import torch
@dataclass(eq=True, frozen=True)
c... | beanmachine-main | src/beanmachine/ppl/model/rv_identifier.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 logging
from enum import Enum
import torch
class LogLevel(Enum):
"""
Enum class mapping the logging levels to numeric valu... | beanmachine-main | src/beanmachine/ppl/model/utils.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
from typing import Optional, Tuple
import numpy as np
import torch
import torch.fft
from torch import Tensor
"""
Common s... | beanmachine-main | src/beanmachine/ppl/diagnostics/common_statistics.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 functools
import math
import warnings
from typing import Callable, Dict, List, Optional, Tuple
import numpy as np
import pandas as p... | beanmachine-main | src/beanmachine/ppl/diagnostics/diagnostics.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.
"""
Tools for supporting MCMC qiagnostics. Will be deprecated in a future release in favor of arviz integration.
"""
from beanmachine.ppl.... | beanmachine-main | src/beanmachine/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.
from typing import Callable, List, NamedTuple, Tuple
import numpy as np
import plotly.graph_objs as go
import torch
from torch import Tenso... | beanmachine-main | src/beanmachine/ppl/diagnostics/common_plots.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.
# flake8: noqa
"""Visual diagnostic tools for Bean Machine models."""
import sys
from pathlib import Path
if sys.version_info >= (3, 8):
... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/__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.
"""Visual diagnostics tools for Bean Machine models."""
from __future__ import annotations
from functools import wraps
from typing import C... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/viz.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.
| beanmachine-main | src/beanmachine/ppl/diagnostics/tools/trace/__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.
"""Methods used to generate the diagnostic tool."""
from typing import List
from beanmachine.ppl.diagnostics.tools.trace import typing
from... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/trace/utils.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.
"""Trace diagnostic tool types for a Bean Machine model."""
from typing import Any, Dict, List, Union
from beanmachine.ppl.diagnostics.tool... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/trace/typing.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.
"""Trace diagnostic tool for a Bean Machine model."""
from __future__ import annotations
from beanmachine.ppl.diagnostics.tools.trace impor... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/trace/tool.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.
| beanmachine-main | src/beanmachine/ppl/diagnostics/tools/marginal1d/__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.
"""Methods used to generate the diagnostic tool."""
from typing import List
import numpy as np
from beanmachine.ppl.diagnostics.tools.margi... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/marginal1d/utils.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.
"""Marginal 1D diagnostic tool types for a Bean Machine model."""
from typing import Any, Dict, List, Union
from beanmachine.ppl.diagnostic... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/marginal1d/typing.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.
"""Marginal 1D diagnostic tool for a Bean Machine model."""
from __future__ import annotations
from beanmachine.ppl.diagnostics.tools.margi... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/marginal1d/tool.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.
"""Plotting utilities for the diagnostic tools."""
from typing import List
from bokeh.core.property.nullable import Nullable
from bokeh.cor... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/utils/plotting_utils.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.
"""Accessor definition for extending Bean Machine `MonteCarloSamples` objects.
These methods are heavily influenced by the implementations ... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/utils/accessor.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.
"""Base class for diagnostic tools of a Bean Machine model."""
from __future__ import annotations
import re
from abc import ABC, abstractme... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/utils/diagnostic_tool_base.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.
| beanmachine-main | src/beanmachine/ppl/diagnostics/tools/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.
"""Collection of serializers for the diagnostics tool use."""
from typing import Dict, List
from beanmachine.ppl.inference.monte_carlo_samp... | beanmachine-main | src/beanmachine/ppl/diagnostics/tools/utils/model_serializers.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 beanmachine.ppl.inference.proposer.single_site_uniform_proposer import (
SingleSiteUniformProposer,
)
from beanmachine.ppl.inferenc... | beanmachine-main | src/beanmachine/ppl/inference/single_site_uniform_mh.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 beanmachine.ppl.inference.proposer.single_site_ancestral_proposer import (
SingleSiteAncestralProposer,
)
from beanmachine.ppl.infe... | beanmachine-main | src/beanmachine/ppl/inference/single_site_ancestral_mh.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 Dict, List, Optional, Union
import torch
from beanmachine.ppl.inference.monte_carlo_samples import MonteCarloSamples
fro... | beanmachine-main | src/beanmachine/ppl/inference/predictive.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 inspect
from collections import defaultdict
from typing import (
Callable,
cast,
Dict,
List,
Optional,
Set,
... | beanmachine-main | src/beanmachine/ppl/inference/compositional_infer.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 copy
import warnings
from abc import ABCMeta, abstractmethod
from functools import partial
from typing import List, Optional, Set, Tu... | beanmachine-main | src/beanmachine/ppl/inference/base_inference.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 logging
from typing import List, Set
import torch.distributions as dist
from beanmachine.ppl.inference.base_inference import BaseInf... | beanmachine-main | src/beanmachine/ppl/inference/single_site_nmc.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 beanmachine.ppl.inference.bmg_inference import BMGInference
from beanmachine.ppl.inference.compositional_infer import CompositionalInfe... | beanmachine-main | src/beanmachine/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.
from typing import List, Set
from beanmachine.ppl.experimental.torch_jit_backend import get_backend
from beanmachine.ppl.inference.base_in... | beanmachine-main | src/beanmachine/ppl/inference/hmc_inference.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 List, Set, Type
from beanmachine.ppl.inference.base_inference import BaseInference
from beanmachine.ppl.inference.propos... | beanmachine-main | src/beanmachine/ppl/inference/single_site_inference.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 List, Set
from beanmachine.ppl.experimental.torch_jit_backend import get_backend
from beanmachine.ppl.inference.base_in... | beanmachine-main | src/beanmachine/ppl/inference/nuts_inference.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 Any, Dict, Iterator, List, Mapping, NamedTuple, Optional, Union
import arviz as az
import torch
import xarray as xr
from... | beanmachine-main | src/beanmachine/ppl/inference/monte_carlo_samples.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 random
from concurrent.futures import ThreadPoolExecutor
from enum import Enum
from typing import Any, Callable, Dict, List
import n... | beanmachine-main | src/beanmachine/ppl/inference/utils.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 __future__ import annotations
import random
import warnings
from types import TracebackType
from typing import Generator, NoReturn, Op... | beanmachine-main | src/beanmachine/ppl/inference/sampler.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.
"""An inference engine which uses Bean Machine Graph to make
inferences on Bean Machine models."""
from typing import Dict, List, Optional,... | beanmachine-main | src/beanmachine/ppl/inference/bmg_inference.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 List, Set
from beanmachine.ppl.inference.base_inference import BaseInference
from beanmachine.ppl.inference.proposer.bas... | beanmachine-main | src/beanmachine/ppl/inference/single_site_random_walk.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 abc import ABCMeta, abstractmethod
from typing import Iterable
import torch
from beanmachine import ppl as bm
from beanmachine.ppl.dis... | beanmachine-main | src/beanmachine/ppl/inference/vi/autoguide.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 .autoguide import ADVI, MAP
from .variational_infer import VariationalInfer
__all__ = [
"ADVI",
"MAP",
"VariationalInfer",... | beanmachine-main | src/beanmachine/ppl/inference/vi/__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.
from __future__ import annotations
from typing import Mapping, MutableMapping, Optional
import torch
import torch.distributions as dist
fr... | beanmachine-main | src/beanmachine/ppl/inference/vi/variational_world.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.
"Gradient estimators of f-divergences."
from typing import Callable, Mapping
import torch
from beanmachine.ppl.inference.vi.variational_wo... | beanmachine-main | src/beanmachine/ppl/inference/vi/gradient_estimator.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 __future__ import annotations
import logging
from typing import Callable, Dict, Optional
import torch
import torch.optim as optim
fro... | beanmachine-main | src/beanmachine/ppl/inference/vi/variational_infer.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.
"Csiszar f-functions in log-space."
import torch
def kl_reverse(logu: torch.Tensor) -> torch.Tensor:
"""
Log-space Csiszar functi... | beanmachine-main | src/beanmachine/ppl/inference/vi/discrepancy.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 NamedTuple, Set, Tuple
import torch
from beanmachine.ppl.experimental.torch_jit_backend import jit_compile, TorchJITBack... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nuts_proposer.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.