python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
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. # 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
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import matplotlib.pyplot as plt from datasets import transformations import torch import numpy as np def plot_x2_reconstruc...
Addressing-the-Topological-Defects-of-Disentanglement-main
plot.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ """ Launches experiments locally or on the cluster python run_experiments.py [name] --cluster OPTIONS: python run_experime...
Addressing-the-Topological-Defects-of-Disentanglement-main
run_experiments_real.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch from torch import nn from collections import OrderedDict from abc import ABC class ResNetExplorer(nn.Module): ...
Addressing-the-Topological-Defects-of-Disentanglement-main
models.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch import numpy as np import functools import pdb class ShiftOperator: """Performs discrete shift based on n_...
Addressing-the-Topological-Defects-of-Disentanglement-main
latent_operators.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """
Addressing-the-Topological-Defects-of-Disentanglement-main
__init__.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch import numpy as np import random import matplotlib import matplotlib.pyplot as plt import models import latent_...
Addressing-the-Topological-Defects-of-Disentanglement-main
weakly_complex_shift_autoencoder.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import copy import torch import json import os import random import numpy as np import models import latent_operators import ...
Addressing-the-Topological-Defects-of-Disentanglement-main
autoencoder.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ """Implements CCI VAE https://arxiv.org/abs/1804.03599 """ import torch import os import numpy as np import models import js...
Addressing-the-Topological-Defects-of-Disentanglement-main
cci_variational_autoencoder.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch import numpy as np import random import matplotlib import matplotlib.pyplot as plt import models import latent_o...
Addressing-the-Topological-Defects-of-Disentanglement-main
complex_shift_autoencoder.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. --- Saves model/plots for best validation MSE """ import math import numpy as np import os from distutils.dir_util import copy_...
Addressing-the-Topological-Defects-of-Disentanglement-main
save_best_validation.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ """ Transformations applied to the input images """ import torch import itertools import numpy as np import skimage.transfor...
Addressing-the-Topological-Defects-of-Disentanglement-main
datasets/transformations.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch from torch.utils.data import Dataset from torchvision import transforms from sklearn.model_selection import Stra...
Addressing-the-Topological-Defects-of-Disentanglement-main
datasets/datasets.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """
Addressing-the-Topological-Defects-of-Disentanglement-main
datasets/__init__.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ """Script demonstrating drawing of anti-aliased lines using Xiaolin Wu's line algorithm usage: python xiaolinwu.py [output-...
Addressing-the-Topological-Defects-of-Disentanglement-main
datasets/xiaolinwu.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ from torch.utils.data import Dataset, DataLoader import numpy as np from PIL import Image from .xiaolinwu import draw_line ...
Addressing-the-Topological-Defects-of-Disentanglement-main
datasets/data_utils.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import pytest from datasets import datasets from cci_variational_autoencoder import CCIVariationalAutoEncoder BATCH_SIZE = 1...
Addressing-the-Topological-Defects-of-Disentanglement-main
tests/test_cci_vae.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch import math from datasets import transformations from datasets import datasets class TestSimpleShapes: def...
Addressing-the-Topological-Defects-of-Disentanglement-main
tests/test_datasets.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import pytest from datasets import datasets from autoencoder import AutoEncoder class TestAutoencoder: @pytest.fixture(...
Addressing-the-Topological-Defects-of-Disentanglement-main
tests/test_autoencoder.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """
Addressing-the-Topological-Defects-of-Disentanglement-main
complex_shift_operator/__init__.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import argparse import torch import sys sys.path.append("..") from datasets import datasets from weakly_complex_shift_autoen...
Addressing-the-Topological-Defects-of-Disentanglement-main
complex_shift_operator/__main__.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.nn as nn from functools import partial from convit import VisionTransformer from timm.model...
convit-main
models.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # """ A script to run multinode training with submitit. """ import argparse import os import uuid from pathlib import P...
convit-main
run_with_submitit.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import os import json import random from torchvision import datasets, transforms from torchvision.datasets.folder imp...
convit-main
datasets.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # """ Train and eval functions used in main.py """ import math import sys from typing import Iterable, Optional import ...
convit-main
engine.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # """ Misc functions, including distributed helpers. Mostly copy-paste from torchvision references. """ import io impor...
convit-main
utils.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import argparse import datetime import numpy as np import time import torch import torch.backends.cudnn as cudnn impor...
convit-main
main.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.distributed as dist import math class RASampler(torch.utils.data.Sampler): """Sampler ...
convit-main
samplers.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # '''These modules are adapted from those of timm, see https://github.com/rwightman/pytorch-image-models/blob/master/tim...
convit-main
convit.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import os import argparse # run each job single-threaded, paralellize using pathos os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" # multi-socket friendly args os.environ["KMP_AFF...
bernoulli_lse-main
init_sensitivity_study.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import os import argparse from copy import deepcopy from pathlib import Path global_seed = 1000 n_reps = 20 if __name__ == "__main__": parser = argparse.ArgumentParser(description="Gentime Benchmarks") parser.add_argument("--nproc",...
bernoulli_lse-main
gentime_bench.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import numpy as np import torch from aepsych.benchmark.test_functions import ( modified_hartmann6, discrim_highdim, novel_discrimination_testfun, ) from aepsych.models import GPClassificationModel from aepsych.benchmark.problem im...
bernoulli_lse-main
problems.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import os import argparse # run each job single-threaded, paralellize using pathos os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" # multi-socket friendly args os.environ["KMP_AFF...
bernoulli_lse-main
run_experiments.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import os import argparse # run each job single-threaded, paralellize using pathos os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" # multi-socket friendly args os.environ["KMP_AFF...
bernoulli_lse-main
thresh_sensitivity_study.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. from pathlib import Path import pandas as pd import numpy as np from plot_config import * run_data = list(Path("../data/gentime_bench/").glob("*out.csv")) import re def make_figure(): alld = [] for f in run_data: dlocal = pd...
bernoulli_lse-main
figures/plot_gentimes.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. from matplotlib import pyplot as plt from matplotlib.lines import Line2D from matplotlib import rc import matplotlib rc('font', family='serif', style='normal', variant='normal', weight='normal', stretch='normal', size=8) matplotlib.rcParams['ps....
bernoulli_lse-main
figures/plot_config.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import numpy as np from contrast_discrimination.helpers import HalfGrating from psychopy import visual, monitors screen = monitors.Monitor("testMonitor", gamma=1) win = visual.Window( allowGUI=True, units="deg", monitor=screen, ...
bernoulli_lse-main
figures/make_stim_plots.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. import numpy as np import pandas as pd from copy import deepcopy import sys sys.path.append("..") from plot_config import * from plot_experiment_results import compile_results, run_data def make_classerr_figure(): res, itrs = compile_re...
bernoulli_lse-main
figures/plot_supplement_experiment_results.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
bernoulli_lse-main
figures/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. from copy import deepcopy import numpy as np import torch from botorch.utils.sampling import draw_sobol_samples import sys sys.path.append('..') from plot_config import * from problems import DiscrimLowDim from aepsych.models.gp_classificat...
bernoulli_lse-main
figures/plot_acquisition.py