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.
from typing import Callable, Optional, Tuple, Union
import torch
import torch.distributions as dist
from beanmachine.ppl.model.rv_identifie... | beanmachine-main | src/beanmachine/ppl/inference/proposer/newtonian_monte_carlo_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 torch.distributions as dist
from beanmachine.ppl.inference.proposer.base_single_site_mh_proposer import (
BaseSingleSiteMHPropose... | beanmachine-main | src/beanmachine/ppl/inference/proposer/single_site_ancestral_proposer.py |
beanmachine-main | src/beanmachine/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 math
from abc import abstractmethod
import torch
import torch.distributions as dist
from beanmachine.ppl.inference.proposer.base_pro... | beanmachine-main | src/beanmachine/ppl/inference/proposer/base_single_site_mh_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 torch
import torch.distributions as dist
class NormalEig(dist.Distribution):
"""
A multivariate normal distribution where t... | beanmachine-main | src/beanmachine/ppl/inference/proposer/normal_eig.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
import torch.distributions as dist
from beanmachine.ppl.inference.proposer.base_single_site_mh_proposer import (
BaseSingle... | beanmachine-main | src/beanmachine/ppl/inference/proposer/single_site_uniform_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 math
import warnings
from typing import cast, Dict, Set, Union
import torch
import torch.distributions as dist
from beanmachine.ppl.... | beanmachine-main | src/beanmachine/ppl/inference/proposer/hmc_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 torch
import torch.distributions as dist
from beanmachine.ppl.inference.proposer.single_site_ancestral_proposer import (
SingleSi... | beanmachine-main | src/beanmachine/ppl/inference/proposer/single_site_random_walk_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 typing import Dict, Generic, TypeVar
import torch
KeyType = TypeVar("KeyType")
class DictToVecConverter(Generic[KeyType]):
"""
... | beanmachine-main | src/beanmachine/ppl/inference/proposer/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 abc import ABCMeta, abstractmethod
from typing import Tuple
import torch
from beanmachine.ppl.world import World
class BaseProposer(... | beanmachine-main | src/beanmachine/ppl/inference/proposer/base_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 math
import warnings
from typing import Callable, Optional, Set, Tuple
import torch
from beanmachine.ppl.experimental.torch_jit_back... | beanmachine-main | src/beanmachine/ppl/inference/proposer/hmc_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 typing import cast, List, Tuple
import torch
from beanmachine.ppl.inference.proposer.base_proposer import BaseProposer
from beanmachin... | beanmachine-main | src/beanmachine/ppl/inference/proposer/sequential_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 logging
from typing import Callable, Optional, Tuple, TypeVar
from typing_extensions import ParamSpec
logger = logging.getLogger(__... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nnc/__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
import torch
import torch.jit
from functorch.compile import nnc_jit
# the warning will only be shown to user once when th... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nnc/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 logging
from typing import Tuple
import torch
import torch.distributions as dist
from beanmachine.ppl.inference.proposer.newtonian_m... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nmc/single_site_simplex_space_nmc_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 logging
from typing import Tuple
import torch
import torch.distributions as dist
from beanmachine.ppl.inference.proposer.newtonian_m... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nmc/single_site_half_space_nmc_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 beanmachine.ppl.inference.proposer.nmc.single_site_half_space_nmc_proposer import (
SingleSiteHalfSpaceNMCProposer,
)
from beanmach... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nmc/__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 logging
from typing import NamedTuple, Optional, Tuple, Union
import torch
import torch.distributions as dist
from beanmachine.ppl.i... | beanmachine-main | src/beanmachine/ppl/inference/proposer/nmc/single_site_real_space_nmc_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.
#
# Tensorizing and detensorizing
#
# See the comment at the top of devectorizer_transformer.py for a high-level description of
# what this ... | beanmachine-main | src/beanmachine/ppl/compiler/tensorizer_transformer.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.
"""Error reporting for internal compiler errors"""
import os
from ast import AST
from tempfile import NamedTemporaryFile
from typing import... | beanmachine-main | src/beanmachine/ppl/compiler/internal_error.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.
# See notes in typer_base.py for how the type computation logic works.
#
# This typer computes all possible tensor values that a graph node ... | beanmachine-main | src/beanmachine/ppl/compiler/support.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, List
import beanmachine.ppl.compiler.bmg_nodes as bn
import torch
from beanmachine.ppl.compiler.bm_graph_buil... | beanmachine-main | src/beanmachine/ppl/compiler/gen_bmg_cpp.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 pattern matching engine"""
from abc import ABC, ABCMeta, abstractmethod
from typing import Any, Callable, Dict, ... | beanmachine-main | src/beanmachine/ppl/compiler/patterns.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.
# See notes in typer_base.py for how the type computation logic works.
#
# This typer identifies the tensor size associated with a graph nod... | beanmachine-main | src/beanmachine/ppl/compiler/sizer.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.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder
from beanmachine.ppl.co... | beanmachine-main | src/beanmachine/ppl/compiler/fix_bool_comparisons.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.statistical_model import functional, random_variable
allowed_functions = {dict, list, set, super, random_variabl... | beanmachine-main | src/beanmachine/ppl/compiler/beanstalk_common.py |
beanmachine-main | src/beanmachine/ppl/compiler/__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.
#
# Tensorizing and detensorizing
#
# TODO: The fact that we use vectorizing and tensorizing as synonyms throughout all this code is
# unnec... | beanmachine-main | src/beanmachine/ppl/compiler/devectorizer_transformer.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.
"""Debugging tools for working with ASTs"""
# This module just has some helpful tools that can be used for visualizing
# Python ASTs when d... | beanmachine-main | src/beanmachine/ppl/compiler/ast_tools.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 rules engine for tree transformation"""
from abc import ABC, abstractmethod
from typing import Any, Callable, Di... | beanmachine-main | src/beanmachine/ppl/compiler/rules.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.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder
from beanmachine.ppl.co... | beanmachine-main | src/beanmachine/ppl/compiler/fix_bool_arithmetic.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 defaultdict
from typing import Dict, List
from beanmachine.ppl.compiler import bmg_nodes as bn
from beanmachine.p... | beanmachine-main | src/beanmachine/ppl/compiler/gen_bm_python.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
import typing
from typing import Callable, Dict, List, Optional, Type
import beanmachine.ppl.compiler.bmg_nodes as bn
f... | beanmachine-main | src/beanmachine/ppl/compiler/copy_and_replace.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 module takes a Bean Machine Graph builder and makes a best
effort attempt to transform the accumulated graph to meet the
requirement... | beanmachine-main | src/beanmachine/ppl/compiler/fix_requirements.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.
"""Tools to transform Bean Machine programs to Bean Machine Graph"""
# TODO: This module is badly named; it really s... | beanmachine-main | src/beanmachine/ppl/compiler/single_assignment.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.
# TODO: Update this comment
"""A builder for the BeanMachine Graph language
The Beanstalk compiler has, at a high level, five phases.
* F... | beanmachine-main | src/beanmachine/ppl/compiler/runtime.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 typing
from typing import Callable, List
from torch import Size
def identity_fnc(a: List[int]) -> List[int]:
retur... | beanmachine-main | src/beanmachine/ppl/compiler/broadcaster.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, ABCMeta
from typing import Any, Iterable, List
import beanmachine.ppl.compiler.bmg_types as bt
import torch
from beanm... | beanmachine-main | src/beanmachine/ppl/compiler/bmg_nodes.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 beanmachine.ppl.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder im... | beanmachine-main | src/beanmachine/ppl/compiler/copy_transformer.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, Optional, Tuple, Type, Union
import beanmachine.ppl.compiler.bmg_nodes as bn
from beanmachine.ppl.compil... | beanmachine-main | src/beanmachine/ppl/compiler/fix_problem.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
import beanmachine.ppl.compiler.bmg_nodes as bn
import torch
from beanmachine.ppl.compiler.bm_graph_builder i... | beanmachine-main | src/beanmachine/ppl/compiler/gen_bmg_python.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.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder
from beanmachine.ppl.co... | beanmachine-main | src/beanmachine/ppl/compiler/fix_logsumexp.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.
# See notes in typer_base.py for how the type computation logic works.
# See notes in bmg_types.py for the type lattice documentation.
#
# T... | beanmachine-main | src/beanmachine/ppl/compiler/lattice_typer.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, Set, Tuple
import beanmachine.ppl.compiler.profiler as prof
from beanmachine.ppl.compiler.bm_graph_build... | beanmachine-main | src/beanmachine/ppl/compiler/fix_problems.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
import beanmachine.ppl.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilde... | beanmachine-main | src/beanmachine/ppl/compiler/fix_multiary_ops.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.compiler.bm_graph_builder import BMGraphBuilder
from beanmachine.ppl.compiler.bmg_types import (
Boolean,
Natur... | beanmachine-main | src/beanmachine/ppl/compiler/fix_observations.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.
# TODO: For reasons unknown, Pyre is unable to find type information about
# TODO: beanmachine.graph from beanmachine.ppl. I'll figure out ... | beanmachine-main | src/beanmachine/ppl/compiler/bmg_node_types.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.
# In lattice_typer.py we assign a type to every node in a graph.
# If the node or any ancestor node is unsupported in BMG then the node
# is... | beanmachine-main | src/beanmachine/ppl/compiler/bmg_requirements.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.compiler.bmg_nodes as bn
import beanmachine.ppl.compiler.bmg_types as bt
from beanmachine.ppl.compiler.bm_graph_build... | beanmachine-main | src/beanmachine/ppl/compiler/fix_additions.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.
"""
Visualize the contents of a builder in the DOT graph language.
"""
from typing import Set
from beanmachine.ppl.compiler.bm_graph_builde... | beanmachine-main | src/beanmachine/ppl/compiler/gen_dot.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 List
import beanmachine.ppl.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import B... | beanmachine-main | src/beanmachine/ppl/compiler/fix_normal_conjugate_prior.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.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBu... | beanmachine-main | src/beanmachine/ppl/compiler/size_assessment.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 beanmachine.ppl.compiler.bmg_nodes as bn
import beanmachine.ppl.compiler.bmg_types as bt
fro... | beanmachine-main | src/beanmachine/ppl/compiler/fix_unsupported.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
from typing import Any, Dict, List, Optional
import beanmachine.ppl.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_g... | beanmachine-main | src/beanmachine/ppl/compiler/gen_mini.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.
"""
Convert a builder into a program that produces a graph builder.
"""
from typing import Dict
import beanmachine.ppl.compiler.bmg_nodes ... | beanmachine-main | src/beanmachine/ppl/compiler/gen_builder.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.compiler.bmg_nodes as bn
import beanmachine.ppl.compiler.bmg_types as bt
from beanmachine.ppl.compiler.bm_graph_build... | beanmachine-main | src/beanmachine/ppl/compiler/fix_transpose.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
import math
import operator
from types import MethodType
from typing import Any, Callable, Dict, List, NoReturn, Optional, S... | beanmachine-main | src/beanmachine/ppl/compiler/special_function_caller.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, Callable, Dict, List, Optional, Set
from beanmachine.ppl.compiler.bmg_nodes import BMGNode
from beanmachine.ppl.uti... | beanmachine-main | src/beanmachine/ppl/compiler/execution_context.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.
"""Pattern matching for ASTs"""
import ast
from platform import python_version
from typing import Any, Dict
from bea... | beanmachine-main | src/beanmachine/ppl/compiler/ast_patterns.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
import beanmachine.ppl.compiler.bmg_nodes as bn
from torch import Tensor
def _tensor_to_label(t: Tensor... | beanmachine-main | src/beanmachine/ppl/compiler/graph_labels.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, Tuple
import beanmachine.ppl.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGrap... | beanmachine-main | src/beanmachine/ppl/compiler/fix_beta_conjugate_prior.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.
# Once we have accumulated a graph we often need to associate type information
# with some or all of the nodes. This presents a number of pr... | beanmachine-main | src/beanmachine/ppl/compiler/typer_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.
import time
from typing import Dict, List, Optional
accumulate = "accumulate"
infer = "infer"
fix_problems = "fix_problems"
graph_infer = ... | beanmachine-main | src/beanmachine/ppl/compiler/profiler.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 Any, Callable, Dict, List, Optional
import beanmachine.ppl.compiler.bmg_nodes as bn
import beanmachine.ppl.c... | beanmachine-main | src/beanmachine/ppl/compiler/bm_graph_builder.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 abstractmethod
from typing import Any, Union
import torch
from beanmachine.ppl.utils.memoize import memoize, MemoizedClass
... | beanmachine-main | src/beanmachine/ppl/compiler/bmg_types.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.compiler.bm_graph_builder import BMGraphBuilder
from beanmachine.ppl.compiler.bmg_nodes import (
BernoulliNode,
... | beanmachine-main | src/beanmachine/ppl/compiler/fix_observe_true.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 as json_
from typing import Any, Optional
from beanmachine.ppl.compiler.profiler import event_list_to_report
class Performanc... | beanmachine-main | src/beanmachine/ppl/compiler/performance_report.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 module declares types used for error detection and reporting
when compiling Bean Machine models to Bean Machine Graph."""
from abc ... | beanmachine-main | src/beanmachine/ppl/compiler/error_report.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.compiler.bmg_nodes as bn
from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder
from beanmachine.ppl.c... | beanmachine-main | src/beanmachine/ppl/compiler/fix_matrix_scale.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, Set
import beanmachine.ppl.compiler.bmg_nodes as bn
import beanmachine.ppl.compiler.profiler as prof
import ... | beanmachine-main | src/beanmachine/ppl/compiler/gen_bmg_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 typing import Optional
import beanmachine.ppl.compiler.bmg_nodes as bn
import beanmachine.ppl.compiler.bmg_types as bt
from beanmachin... | beanmachine-main | src/beanmachine/ppl/compiler/fix_arithmetic.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.
"""Tools to transform Bean Machine programs to Bean Machine Graph"""
import ast
import inspect
import sys
import typ... | beanmachine-main | src/beanmachine/ppl/compiler/bm_to_bmg.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
import torch.distributions as dist
class Flat(dist.Distribution):
"""
Flat distribution used as an improper prior. Sa... | beanmachine-main | src/beanmachine/ppl/distributions/flat.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.distributions.delta import Delta
from beanmachine.ppl.distributions.flat import Flat
from beanmachine.ppl.distributions... | beanmachine-main | src/beanmachine/ppl/distributions/__init__.py |
# @lint-ignore-every LICENSELINT
# Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
def broadcast_shape(*shapes, **kwargs):
"""
Similar to ``np.broadcast()`` but for shapes.
Equivalent to ``np.broadcast(*map(np.empt... | beanmachine-main | src/beanmachine/ppl/distributions/unit.py |
# @lint-ignore-every LICENSELINT
# Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import numbers
import torch
from torch.distributions import constraints, Distribution
# Helper function
def sum_rightmost(value, dim):
if isinstance(value, numbers.Number):
return value
... | beanmachine-main | src/beanmachine/ppl/distributions/delta.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/tutorials/__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.
"""Module defining a data extract, transform, and load API."""
import logging
from pathlib import Path
from typing import Any
import pandas... | beanmachine-main | src/beanmachine/tutorials/utils/etl.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.tutorials.utils import etl, plots
__all__ = ["etl", "plots"]
| beanmachine-main | src/beanmachine/tutorials/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.
"""Basic plotting methods used in the tutorials."""
from itertools import cycle
from typing import Any, Dict, List, Optional, Tuple, Union
... | beanmachine-main | src/beanmachine/tutorials/utils/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.
"""Data ETL for the radon tutorial."""
from typing import Dict
import arviz as az
import numpy as np
import pandas as pd
import statsmodels... | beanmachine-main | src/beanmachine/tutorials/utils/radon.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.
"""Data ETL for the NBA item response tutorial."""
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource # usort... | beanmachine-main | src/beanmachine/tutorials/utils/nba.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.
"""Module for the ``Mixture model using count data`` tutorial."""
from numbers import Number
from typing import Any, Dict, List, Union
impo... | beanmachine-main | src/beanmachine/tutorials/utils/hearts.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.
"""Helper module for the hierarchical model tutorial."""
from typing import Dict, List
import arviz as az
import numpy as np
import pandas ... | beanmachine-main | src/beanmachine/tutorials/utils/baseball.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from keras import backend as K
from keras.preprocessing.image import ImageDataGenerator
class TANDAImageDataGenerator(ImageDataGenerator):
"""Generate minibatches o... | tanda-master | keras/tanda_keras.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import json
from experiments.train_scripts import GENERATORS
from experiments.utils import parse_config_str
from keras import backend as K
from tanda.generator import (
... | tanda-master | keras/utils.py |
'''Train a simple deep CNN on the CIFAR10 small images dataset.
Replicated from `keras/examples/cifar10_cnn.py` to demonstrate
`TANDAImageDataGenerator` usage. By default, we subsample to 10% of the training
data to benchmark data augmentation performance.
'''
from __future__ import absolute_import
from __future__ i... | tanda-master | keras/keras_cifar10_example.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import json
import os
import pandas as pd
from collections import defaultdict
if __name__ == '__main__':
parser = argparse.ArgumentParser(
... | tanda-master | experiments/print_tan_stats.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import json
import numpy as np
import subprocess
import time
from .utils import create_config_str, get_log_dir_path, num_procs_open
from collections impo... | tanda-master | experiments/launch_run.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import json
import numpy as np
import os
import subprocess
import time
from .utils import get_log_dir_path, num_procs_open
from collections import Ordere... | tanda-master | experiments/launch_end_models.py |
tanda-master | experiments/__init__.py | |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import json
import numpy as np
import os
import sys
import tensorflow as tf
from collections import Counter, defaultdict
from scipy.misc import imsave
from six import it... | tanda-master | experiments/utils.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import numpy as np
import os
import re
import tensorflow as tf
import tensorflow.contrib.slim as slim
from .utils import parse_config_str
from collections import Ordered... | tanda-master | experiments/train_scripts.py |
tanda-master | experiments/mnist/__init__.py | |
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | tanda-master | experiments/mnist/dataset.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
from dataset import read_data_sets
from experiments.train_scripts import flags, select_fold, train
from experiments.tfs.image import *
from functools import pa... | tanda-master | experiments/mnist/train.py |
tanda-master | experiments/tfs/__init__.py | |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import numpy as np
from PIL import Image, ImageEnhance
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.interpolation import map_coordinates
from ski... | tanda-master | experiments/tfs/image/image_tfs.py |
from .image_tfs import *
| tanda-master | experiments/tfs/image/__init__.py |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import numpy as np
import tensorflow as tf
from matplotlib import pyplot as plt
from tanda.discriminator import Discriminator
def generate_data(n, d=2, r=1, l=1, insid... | tanda-master | experiments/synthetic/utils.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.