python_code stringlengths 0 4.04M | repo_name stringlengths 8 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import math
import torch
import torch.utils.data as data_utils
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.a... | CausalRepID-main | algorithms/base_auto_encoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import math
import torch
import torch.utils.data as data_utils
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.a... | CausalRepID-main | algorithms/image_auto_encoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import math
import torch
import torch.utils.data as data_utils
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.a... | CausalRepID-main | algorithms/ioss_auto_encoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
import copy
import torch
import torchvision
import numpy as np
from sklearn.metrics import r2_score
from sklearn.linear_model import LinearRegression, Lasso, Ridge, LassoCV, RidgeCV
from sklearn.linear_model import LogisticRegression
fro... | CausalRepID-main | utils/metrics.py |
CausalRepID-main | utils/__init__.py | |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import numpy as np
import torch
import torch.utils.data as data_utils
path= os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(path)
from data.data_loader import BaseDataLoader
from data.fine_tune... | CausalRepID-main | utils/helper.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from torch import nn
class LinearAutoEncoder(torch.nn.Module):
def __init__(self, data_dim, latent_dim, batch_norm= False):
super(LinearAutoEncoder, self).__init__()
self.data_dim = data_dim
... | CausalRepID-main | models/linear_auto_encoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.utils.data
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.autograd import Variable
from torchvision.models.... | CausalRepID-main | models/decoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.utils.data
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.autograd import Variable
from torchvision.models.... | CausalRepID-main | models/image_resnet_decoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.utils.data
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.autograd import Variable
from torchvision.models.... | CausalRepID-main | models/poly_decoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from torch import nn
class Encoder(torch.nn.Module):
def __init__(self, data_dim, latent_dim):
super(Encoder, self).__init__()
self.data_dim = data_dim
self.latent_dim = latent_dim
... | CausalRepID-main | models/encoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.utils.data
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.autograd import Variable
from torchvision.models.... | CausalRepID-main | models/image_decoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from torch import nn
from torchvision import models as vision_models
from torchvision.models import resnet18, resnet50
from torchvision import transforms
class ImageEncoder(torch.nn.Module):
def __init__(self, latent_dim):
... | CausalRepID-main | models/image_encoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.utils.data
from torch import nn, optim
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.autograd import Variable
from torchvision.models.... | CausalRepID-main | models/image_slot_attention_decoder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import numpy as np
import pandas as pd
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--case', type=str, default='log',
help= 'test; log; debug')
parser.add_argument('--target_latent... | CausalRepID-main | scripts/main_exps_images.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
import scipy
import copy
from sklearn.linear_model import LinearRegression, Lasso, Ridge, LassoCV, RidgeCV
'''
z: True Latent (dataset_size, latent_dim) (.npy file)
Pred_z: Inferred Latent (dataset_size, latent_dim) (.npy file)
... | CausalRepID-main | scripts/test_metrics.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import numpy as np
import pandas as pd
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--case', type=str, default='log',
help= 'train; test; log; debug')
parser.add_argument('--interv... | CausalRepID-main | scripts/main_exps.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import random
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
import os
import sys
path= os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(path)
from data.dag_generator import DagGenerator
ran... | CausalRepID-main | scripts/dag_gen_debug.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import math
import argparse
import numpy as np
import time
## Imports for plotting
import matplotlib.pyplot as plt
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('svg', 'pdf') # For export
from matplotlib.colors... | CausalRepID-main | scripts/ioss.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import copy
import numpy as np
import torch
import torch.utils.data as data_utils
from torchvision import datasets, transforms
from sklearn.preprocessing import StandardScaler
# Base Class
from data.data_loader import BaseDataLoader
cl... | CausalRepID-main | data/balls_dataset_loader.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
#Common imports
import sys
import os
import argparse
import random
import copy
import math
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
from sklearn.linear_model... | CausalRepID-main | data/synthetic_polynomial_dgp.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Defining a set of classes that represent causal functions/ mechanisms.
Author: Diviyan Kalainathan
Modified by Philippe Brouillard, July 24th 2019
Modified by Divyat Mahajan, December 30th 2022
.. MIT License
..
.. Copyright (c) 2018 Diviyan K... | CausalRepID-main | data/causal_mechanisms.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import copy
import numpy as np
import torch
import torch.utils.data as data_utils
from torchvision import datasets, transforms
class BaseDataLoader(data_utils.Dataset):
def __init__(self, data_dir='', data_case='train', se... | CausalRepID-main | data/data_loader.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
import random
import argparse
import torch
import numpy as np
import pygame
from pygame import gfxdraw, init
from typing import Callable, Optional
from matplotlib import pyplot as plt
if "SDL_VIDEODRIVER" not in os.environ:
... | CausalRepID-main | data/balls_dataset.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
""" DAG Generator.
Generates a dataset out of an acyclic FCM.
Author : Olivier Goudet and Diviyan Kalainathan
Modified by Philippe Brouillard, June 25th 2019
Modified by Divyat Mahajan, December 30th 2022
.. MIT License
..
.. Copyright (c) 2018 D... | CausalRepID-main | data/dag_generator.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import copy
import numpy as np
import torch
import torch.utils.data as data_utils
from torchvision import datasets, transforms
from sklearn.preprocessing import StandardScaler
#Base Class
from data.data_loader import BaseDataLoader
clas... | CausalRepID-main | data/fine_tune_loader.py |
# Copyright (c) 2017-present, Facebook, Inc.
# 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 glob
import os
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
plt.rc('fo... | DeepConvexity-master | plot.py |
# Copyright (c) 2017-present, Facebook, Inc.
# 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.optim.lr_scheduler import ReduceLROnPlateau
import argparse
import torch
import time
import math
import os
def res... | DeepConvexity-master | main.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from distutils.core import setup
ext_modules = []
cmdclass = {}
with open("requirements.txt", "r") as handle:
install_requires = handle.read().splitlines()
setup(
name="cpa",
version="1.0.0",
description="",
url="http://githu... | CPA-main | setup.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from collections import defaultdict
import matplotlib.font_manager
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from adjustText import adjust_text
from sklearn.decomposition import KernelPCA
from skl... | CPA-main | cpa/plotting.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from cpa.api import API
from cpa.plotting import CPAVisuals
| CPA-main | cpa/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from http.client import RemoteDisconnected
import json
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
class NBLoss(torch.nn.Module):
def __init__(self):
super(NBLoss, self).__init__()
def for... | CPA-main | cpa/model.py |
import copy
import itertools
import os
import pprint
import time
from collections import defaultdict
from typing import Optional, Union, Tuple
import numpy as np
import pandas as pd
import scanpy as sc
import torch
from torch.distributions import (
NegativeBinomial,
Normal
)
from cpa.train import evaluate, pre... | CPA-main | cpa/api.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import warnings
import numpy as np
import pandas as pd
import scanpy as sc
from sklearn.metrics import r2_score
from scipy.sparse import issparse
from scipy.stats import wasserstein_distance
import torch
warnings.filterwarnings("ignore")
import ... | CPA-main | cpa/helper.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import json
import os
import time
from collections import defaultdict
import numpy as np
import torch
from cpa.data import load_dataset_splits
from cpa.model import CPA, MLP
from sklearn.metrics import r2_score
from torch.autograd ... | CPA-main | cpa/train.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import warnings
import numpy as np
import torch
warnings.simplefilter(action="ignore", category=FutureWarning)
from typing import Union
import pandas as pd
import scanpy as sc
import scipy
from cpa.helper import rank_genes_groups
from sklearn.pr... | CPA-main | cpa/data.py |
import sys
sys.path.append("../")
import cpa
import scanpy as sc
import scvi
from cpa.helper import rank_genes_groups_by_cov
def sim_adata():
adata = scvi.data.synthetic_iid(run_setup_anndata=False)
sc.pp.filter_cells(adata, min_counts=0)
sc.pp.log1p(adata)
adata.obs["condition"] = "drugA"
adata... | CPA-main | tests/test.py |
"""
Copyright (c) Facebook, Inc. and its 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
import os
from functools import partial
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pa... | decodable_information_bottleneck-main | aggregate.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
Script to use to change directory structure in `tmp_results/*` in case you change the default
directory structure (i.e. you change `hyperparamete... | decodable_information_bottleneck-main | add_hyperparam.py |
"""
Copyright (c) Facebook, Inc. and its 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
import os
import string
from copy import deepcopy
import hydra
import matplotlib.pyplot as plt
import numpy as np
import panda... | decodable_information_bottleneck-main | load_models.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import contextlib
import copy
import logging
import math
import os
import subprocess
from functools import partial, partialmethod
from pathli... | decodable_information_bottleneck-main | main.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
# should be in a hydra file
UNLABELLED_CLASS = -1
| decodable_information_bottleneck-main | dib/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .trainer import *
| decodable_information_bottleneck-main | dib/training/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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
import warnings
from contextlib import suppress
import numpy as np
import skorch
import torch
import torch.nn as nn
from scip... | decodable_information_bottleneck-main | dib/training/trainer.py |
"""
Copyright (c) Facebook, Inc. and its 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 random
import warnings
import numpy as np
import skorch
import torch
from skorch.callbacks import Callback
from dib.util... | decodable_information_bottleneck-main | dib/training/helpers.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
Pruning methods modified from:
https://pytorch.org/docs/master/_modules/torch/nn/utils/prune.html
"""
import numbers
from abc import abstractmet... | decodable_information_bottleneck-main | dib/utils/pruning.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| decodable_information_bottleneck-main | dib/utils/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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 random
import numpy as np
import torch
from .helpers import channels_to_last_dim, indep_shuffle_, prod, ratio_to_in... | decodable_information_bottleneck-main | dib/utils/datasplit.py |
"""
Copyright (c) Facebook, Inc. and its 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
import math
import torch
from torch import nn
from torch.nn.init import _calculate_correct_fan
__all__ = ["weights_init"]
l... | decodable_information_bottleneck-main | dib/utils/initialization.py |
"""
Copyright (c) Facebook, Inc. and its 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 torch
from torch.distributions import Categorical, Independent, Normal
def MultivariateNormalDiag(loc, scale_diag):
... | decodable_information_bottleneck-main | dib/utils/distributions.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import contextlib
import math
import operator
import random
import warnings
from functools import reduce
from itertools import zip_longest
i... | decodable_information_bottleneck-main | dib/utils/helpers.py |
"""
Copyright (c) Facebook, Inc. and its 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 partial
import torch.nn as nn
BATCHNORMS = [None, nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d]
def get_norm_laye... | decodable_information_bottleneck-main | dib/predefined/helper_layers.py |
"""
Copyright (c) Facebook, Inc. and its 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 partial
import torch.nn as nn
from .cnn import get_Cnn
from .mlp import MLP
__all__ = ["get_predefined", "try_get_pr... | decodable_information_bottleneck-main | dib/predefined/predefined.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .cnn import *
from .imgs import *
from .mlp import *
from .predefined import *
| decodable_information_bottleneck-main | dib/predefined/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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
import warnings
from functools import partial
import numpy as np
import torch
import torch.nn as nn
from torch.nn import func... | decodable_information_bottleneck-main | dib/predefined/cnn.py |
"""
Copyright (c) Facebook, Inc. and its 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
import warnings
import numpy as np
import torch
import torch.nn as nn
from skorch.utils import to_numpy
from dib.utils.helpe... | decodable_information_bottleneck-main | dib/predefined/mlp.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .ib import *
from .img import *
| decodable_information_bottleneck-main | dib/transformers/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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 functools import partial
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torchvision
fr... | decodable_information_bottleneck-main | dib/transformers/img.py |
"""
Copyright (c) Facebook, Inc. and its 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
import math
import random
from itertools import zip_longest
import numpy as np
import torch
import torch.nn as nn
import torc... | decodable_information_bottleneck-main | dib/transformers/ib/erm.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .dib import *
from .erm import *
from .helpers import *
from .vib import *
| decodable_information_bottleneck-main | dib/transformers/ib/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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 logging
import math
import random
from functools import partial
from itertools import zip_longest
import numpy as np
impo... | decodable_information_bottleneck-main | dib/transformers/ib/dib.py |
"""
Copyright (c) Facebook, Inc. and its 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
import math
import random
from itertools import zip_longest
import numpy as np
import torch
import torch.nn as nn
import torc... | decodable_information_bottleneck-main | dib/transformers/ib/vib.py |
"""
Copyright (c) Facebook, Inc. and its 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
import numpy as np
import torch
from dib.utils.helpers import mean_p_logits
__all__ = ["BASE_LOG", "N_CORR"]
logger = loggi... | decodable_information_bottleneck-main | dib/transformers/ib/helpers.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .mcclf import *
| decodable_information_bottleneck-main | dib/classifiers/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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 torch
import torch.nn as nn
from dib.utils.helpers import mean_p_logits
__all__ = ["MCTrnsfClassifier"]
class M... | decodable_information_bottleneck-main | dib/classifiers/mcclf.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .data import *
from .evaluate import *
from .train import *
from .visualize import *
| decodable_information_bottleneck-main | utils/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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
import os
import shutil
import skorch
import torch
from skorch.callbacks import EarlyStopping, LoadInitState, ProgressBar
from... | decodable_information_bottleneck-main | utils/train.py |
"""
Copyright (c) Facebook, Inc. and its 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 glob
import logging
import math
import os
from functools import partial, partialmethod
import numpy as np
import pandas a... | decodable_information_bottleneck-main | utils/evaluate.py |
"""
Copyright (c) Facebook, Inc. and its 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 copy
import glob
import logging
import math
import os
import random
import shutil
import types
from collections imp... | decodable_information_bottleneck-main | utils/helpers.py |
"""
Copyright (c) Facebook, Inc. and its 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
import sys
import warnings
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
from matplo... | decodable_information_bottleneck-main | utils/visualize/visualize_clf.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .visualize_clf import *
from .visualize_imgs import *
| decodable_information_bottleneck-main | utils/visualize/__init__.py |
"""
Copyright (c) Facebook, Inc. and its 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
# example : https://github.com/matplotlib/matplotlib/issues/7008
def kwargs_log_xscale(x_data, mode="equidistant", base=... | decodable_information_bottleneck-main | utils/visualize/helpers.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import random
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np
import seaborn as sns
import t... | decodable_information_bottleneck-main | utils/visualize/visualize_imgs.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import glob
import logging
import os
import numpy as np
import torch
from PIL import Image
from torch.utils.data import Dataset
from torchvi... | decodable_information_bottleneck-main | utils/data/imgs.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
def get_train_dev_test_datasets(dataset, data_type, valid_size=0.1, **kwargs):
"""Return the correct instantiated train, validation, tes... | decodable_information_bottleneck-main | utils/data/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import numpy as np
import torch
from dib.utils.datasplit import RandomMasker
from dib.utils.helpers import tmp_seed, to_numpy
d... | decodable_information_bottleneck-main | utils/data/helpers.py |
"""
Copyright (c) Facebook, Inc. and its 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 logging
import os
import random
import numpy as np
import torch
from sklearn.model_selection import train_test_split
from... | decodable_information_bottleneck-main | utils/data/base.py |
AVT-main | __init__.py | |
# Copyright (c) Facebook, Inc. and its affiliates.
"""Launch script to run arguments stored in txt files."""
import argparse
import subprocess
import os
import socket
import glob
from omegaconf import OmegaConf
import inquirer
import pathlib
from hydra.core.override_parser.overrides_parser import OverridesParser
from... | AVT-main | launch.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""Main training entry."""
import os
import logging
import random
import subprocess
import torch
import hydra
from omegaconf import DictConfig, OmegaConf
import func
OmegaConf.register_new_resolver('minus', lambda x, y: x - y)
# Multiply and cast to integer
Omega... | AVT-main | train_net.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""The Epic Kitchens dataset loaders."""
from typing import List, Dict, Sequence, Tuple, Union
from datetime import datetime, date
from collections import OrderedDict
import pickle as pkl
import csv
import logging
from pathlib import Path
import lmdb
import pandas as... | AVT-main | datasets/epic_kitchens.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""The base dataset loader."""
from typing import Tuple, Union, Sequence, Dict
import logging
from pathlib import Path
from collections import OrderedDict
import operator
from multiprocessing import Manager
import math
import h5py
import pandas as pd
import numpy as... | AVT-main | datasets/base_video_dataset.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""Implementation of reader functions."""
import logging
from pathlib import Path
import torch
import torch.nn as nn
import torchvision
from common.utils import get_video_info
# An abstract class to keep track of all reader type classes
class Reader(nn.Module):
... | AVT-main | datasets/reader_fns.py |
AVT-main | datasets/__init__.py | |
# Copyright (c) Facebook, Inc. and its affiliates.
"""The Breakfast/50Salads dataset loader.
"""
from pathlib import Path
import logging
import pandas as pd
from tqdm import tqdm
import gzip
import numpy as np
import torch
import torch.nn as nn
import hydra
from hydra.types import TargetConf
from common.utils impor... | AVT-main | datasets/breakfast_50salads.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import os
import torch
from importlib import import_module
from tqdm import tqdm
import omegaconf
import hydra
from common import utils
__all__ = [
"get_dataset",
]
def get_dataset(dataset_cfg, data_cfg, transform, logger):
# If there is _precomputed_meta... | AVT-main | datasets/data.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""
Implementation of the future features prediction models.
Input: (B, C)
Output: (B, C)
"""
import torch
import torch.nn as nn
import transformers
import logging
import hydra
from common.cluster import KmeansAssigner
class Identity(nn.Module):
"""Wrap... | AVT-main | models/future_prediction.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""
Implementation of the temporal aggregation algorithms.
Input: (B, C, T)
Output: (B, C)
"""
import math
import torch
import torch.nn as nn
import logging
import warnings
try:
from external.rulstm.RULSTM.models import RULSTM
except ImportError:
RULS... | AVT-main | models/temporal_aggregation.py |
AVT-main | models/__init__.py | |
# Copyright (c) Facebook, Inc. and its affiliates.
"""
Model architectures.
"""
import torch.nn as nn
from torchvision.models.video.resnet import (
BasicBlock,
Bottleneck,
R2Plus1dStem,
_video_resnet,
)
from pretrainedmodels import bninception
import timm
__all__ = [
'r2plus1d_34',
'r2plus1d_1... | AVT-main | models/video_classification.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""
The overall base model.
"""
from typing import Dict, Tuple
import operator
import torch
import torch.nn as nn
import hydra
from omegaconf import OmegaConf
CLS_MAP_PREFIX = 'cls_map_'
PAST_LOGITS_PREFIX = 'past_'
class BaseModel(nn.Module):
def __init__(self... | AVT-main | models/base_model.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import torch.nn as nn
class MLP(nn.Module):
def __init__(self, in_features, out_features, nlayers, **kwargs):
super().__init__()
layers = [[nn.Linear(in_features, in_features, **kwargs),
nn.ReLU()] for _ in range(nlayers - 1)]
... | AVT-main | models/classifiers.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import torch
import numbers
import random
from torchvision.transforms import (
RandomCrop,
RandomResizedCrop,
ColorJitter,
ToPILImage,
ToTensor,
)
__all__ = [
"RandomCropVideo",
"RandomResizedCropVideo",
"CenterCropVideo",
"Normal... | AVT-main | common/transforms.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from collections import defaultdict, deque
import datetime
import time
import logging
import torch
import torch.distributed as dist
from common.utils import is_dist_avail_and_initialized, is_main_process
__all__ = [
'SmoothedValue', 'MetricLogger', 'get_default_... | AVT-main | common/log.py |
from .log import *
| AVT-main | common/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from __future__ import print_function
from typing import List, Dict
import errno
import os
from pathlib import Path
import logging
import submitit
import cv2
import torch
import torch.distributed as dist
def accuracy(output, target, topk=(1, )):
"""Computes th... | AVT-main | common/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import torch
import torch.nn as nn
class KmeansAssigner(nn.Module):
def __init__(self, centroids_fpath, norm=False):
super().__init__()
# NxC dimension
# Not converting this to linear layer as then the weights get
# overwriten dur... | AVT-main | common/cluster.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from typing import Sequence
import torch
from bisect import bisect_right
class WarmupMultiStepLR(torch.optim.lr_scheduler._LRScheduler):
def __init__(
self,
optimizer: torch.optim.Optimizer,
milestone_epochs: Sequence[int],
... | AVT-main | common/scheduler.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import math
import torch
from torch.utils.data import Sampler
import torch.distributed as dist
import torchvision.datasets.video_utils
class DistributedSampler(Sampler):
"""
Extension of DistributedSampler, as discussed in
https://github.com/pytorch/pyto... | AVT-main | common/sampler.py |
AVT-main | external/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.