python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
#!/usr/bin/env python3 # 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 unittest import numpy as np import numpy.testing as npt from aepsych.config import Config fro...
aepsych-main
tests/generators/test_random_generator.py
#!/usr/bin/env python3 # 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 unittest from aepsych.config import Config from aepsych.generators.completion_criterion impor...
aepsych-main
tests/generators/test_completion_criteria.py
#!/usr/bin/env python3 # 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 unittest from unittest.mock import MagicMock import numpy as np import torch from aepsych.acq...
aepsych-main
tests/generators/test_epsilon_greedy_generator.py
#!/usr/bin/env python3 # 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.
aepsych-main
tests/generators/__init__.py
#!/usr/bin/env python3 # 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 unittest import numpy as np import numpy.testing as npt import torch from aepsych.config impo...
aepsych-main
tests/generators/test_sobol_generator.py
#!/usr/bin/env python3 # 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 unittest import numpy as np import numpy.testing as npt from aepsych.config import Config fro...
aepsych-main
tests/generators/test_manual_generator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # Th...
aepsych-main
sphinx/source/conf.py
#!/usr/bin/env python3 # 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 datetime import datetime import numpy as np constants = { "savefolder": "./databases/", ...
aepsych-main
examples/contrast_discrimination_psychopy/experiment_config.py
#!/usr/bin/env python3 # 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 experiment_config import numpy as np import torch from aepsych_client import AEPsychClient fro...
aepsych-main
examples/contrast_discrimination_psychopy/experiment.py
#!/usr/bin/env python3 # 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 numpy as np import pyglet from psychopy import core, event from psychopy.visual import Window ...
aepsych-main
examples/contrast_discrimination_psychopy/helpers.py
#!/usr/bin/env python3 # 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. # we have pretty verbose messaging by default, suppress that here import logging import warnings war...
aepsych-main
pubs/owenetal/code/benchmark_threshold.py
#!/usr/bin/env python3 # 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 copy import copy import matplotlib.pyplot as plt import numpy as np import torch from aepsych....
aepsych-main
pubs/owenetal/code/stratplots.py
#!/usr/bin/env python3 # 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 gpytorch import matplotlib.pyplot as plt import numpy as np import seaborn as sns import torch...
aepsych-main
pubs/owenetal/code/prior_plots.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 scripts directory. from __future__ import annotations import argparse import json import os import nbformat from bs4 import BeautifulSoup from nbconver...
aepsych-main
scripts/parse_tutorials.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 scripts directory. from __future__ import annotations import argparse import os from bs4 import BeautifulSoup #The base_url must match the base url in...
aepsych-main
scripts/parse_sphinx.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. from __future__ import annotations import argparse import json import os import shutil import nbformat from bs4 import BeautifulSoup from nbconvert import HTMLExporter TEMPLATE = """const CWD = process.cwd(); const Rea...
aepsych-main
scripts/parse_demos.py
#!/usr/bin/env python3 # 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 setuptools import setup with open("README.md") as f: readme = f.read() setup( name="BLINK", version...
BLINK-main
setup.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 re import os import pysolr import sys import blink.candidate_retrieval.utils as utils def get_model(params): ...
BLINK-main
blink/candidate_generation.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 prettytable import blink.main_dense as main_dense import blink.candidate_ranking.utils as utils D...
BLINK-main
blink/run_benchmark.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 blink.candidate_ranking.bert_reranking import BertReranker def get_model(params): return BertReranker(params)
BLINK-main
blink/reranker.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 pickle import emoji def get_model(parameters): return Wikimedia_Data_Fetcher(parameters["path_to_candidate_da...
BLINK-main
blink/candidate_data_fetcher.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 json import sys from tqdm import tqdm import logging import torch import numpy as np from colorama...
BLINK-main
blink/main_dense.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. #
BLINK-main
blink/__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 logging import numpy import os import time import torch from blink.indexer.faiss_indexer import De...
BLINK-main
blink/build_faiss_index.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 flair.models import SequenceTagger from flair.data import Sentence def get_model(parameters=None): return Flair...
BLINK-main
blink/ner.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 io import json import os import pickle from segtok.segmenter import split_multi ##### Reading helpers ##### def r...
BLINK-main
blink/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 os import blink.utils as utils import blink.ner as NER import blink.candidate_generation as CG import blink.candid...
BLINK-main
blink/main_solr.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 multiprocessing.pool import ThreadPool from candidate_generators import ( Simple_Candidate_Generator, Pregene...
BLINK-main
blink/candidate_retrieval/perform_and_evaluate_candidate_retrieval_multithreaded.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 pysolr import pickle import emoji import time import os parser = argparse.ArgumentParser() parser...
BLINK-main
blink/candidate_retrieval/data_ingestion.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 pickle import os import argparse import sys parser = argparse.ArgumentParser() parser.add_argument( "--output...
BLINK-main
blink/candidate_retrieval/link_wikipedia_and_wikidata.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 xml.etree.ElementTree as ET import io import re import argparse import os import pickle import sys import urllib.pa...
BLINK-main
blink/candidate_retrieval/process_wiki_extractor_output_links.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 xml.etree.ElementTree as ET import io import re import argparse import os import pickle import sys parser = argpar...
BLINK-main
blink/candidate_retrieval/process_wiki_extractor_output.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 re import pickle import os import time import numpy as np """ This script is adapted from https://github.com/lepho...
BLINK-main
blink/candidate_retrieval/dataset.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 sqlite3 import pickle import os import io import argparse import sys parser = argparse.ArgumentParser() parser.ad...
BLINK-main
blink/candidate_retrieval/enrich_data.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 sys import pickle import subprocess import blink.candidate_retrieval.dataset as D import re import os ESCAPE_CHAR...
BLINK-main
blink/candidate_retrieval/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 pysolr import sys import utils def mention_data_summary(mention): return (mention["mention"], mention["query_...
BLINK-main
blink/candidate_retrieval/candidate_generators.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 xml.etree.ElementTree as ET import io import re import argparse import os import pickle import sys parser = argpar...
BLINK-main
blink/candidate_retrieval/process_wiki_extractor_output_full.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 bz2 import sys import pickle import os import json import argparse parser = argparse.ArgumentParser() parser.add_...
BLINK-main
blink/candidate_retrieval/process_wikidata.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 os import pickle import nltk.data import argparse import sys from tqdm import tqdm parser = argparse.ArgumentPars...
BLINK-main
blink/candidate_retrieval/process_intro_sents.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 sqlite3 import pickle import os import argparse parser = argparse.ArgumentParser() parser.add_argument( "--in...
BLINK-main
blink/candidate_retrieval/generate_wiki2wikidata_mappings.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 import numpy as np from collections import Counter class Evaluator: def __init__(sel...
BLINK-main
blink/candidate_retrieval/evaluator.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 pickle import json import emoji import sys import os import io import blink.candidate_retrieval.ut...
BLINK-main
blink/candidate_retrieval/json_data_generation.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 os import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from collections import O...
BLINK-main
blink/crossencoder/crossencoder.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 sys import numpy as np from tqdm import tqdm import blink.biencoder.data_process as data from blink.c...
BLINK-main
blink/crossencoder/data_process.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 os import argparse import pickle import torch import json import sys import io import random import time import num...
BLINK-main
blink/crossencoder/train_cross.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 json import logging import os import torch from tqdm import tqdm from torch.utils.data import Dat...
BLINK-main
blink/biencoder/eval_biencoder.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. # # Utility code for zeshel dataset import json import torch DOC_PATH = "/private/home/ledell/zeshel/data/documents/" WOR...
BLINK-main
blink/biencoder/zeshel_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 json import logging import torch from tqdm import tqdm import blink.candidate_ranking.utils as utils from blink.b...
BLINK-main
blink/biencoder/nn_prediction.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. #
BLINK-main
blink/biencoder/__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 logging import torch from tqdm import tqdm, trange from torch.utils.data import DataLoader, TensorDataset from py...
BLINK-main
blink/biencoder/data_process.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 os import argparse import pickle import torch import json import sys import io import random import time import num...
BLINK-main
blink/biencoder/train_biencoder.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 os import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from tqdm import tqdm fro...
BLINK-main
blink/biencoder/biencoder.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 os import numpy as np from pytorch_transformers.modeling_bert import ( BertPreTrainedModel, B...
BLINK-main
blink/candidate_ranking/bert_reranking.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 os import io import sys import json import torch import logging import numpy as np from collections import Ordere...
BLINK-main
blink/candidate_ranking/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 os import argparse import pickle import torch import json import sys import io import random import sys import time...
BLINK-main
blink/candidate_ranking/train.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 time import utils import torch import utils import argparse import os from bert_reranking import BertReranker from...
BLINK-main
blink/candidate_ranking/evaluate.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. # # Provide an argument parser and default command line options for using BLINK. import argparse import importlib import os...
BLINK-main
blink/common/params.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 import nn def get_model_obj(model): model = model.module if hasattr(model, "module") else model retur...
BLINK-main
blink/common/ranker_base.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 os import numpy as np from pytorch_transformers.modeling_bert import ( BertPreTrainedModel, B...
BLINK-main
blink/common/optimizer.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. # """ FAISS-based index components. Original from https://github.com/facebookresearch/DPR/blob/master/dpr/indexer/faiss_ind...
BLINK-main
blink/indexer/faiss_indexer.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 json import sys from elq.index.faiss_indexer import DenseFlatIndexer, DenseHNSWFlatIndexer, DenseIV...
BLINK-main
elq/main_dense.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 logging import numpy import os import time import torch from elq.index.faiss_indexer import DenseF...
BLINK-main
elq/build_faiss_index.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. # # Code partially adopted from https://github.com/allenai/allennlp # from typing import Any, Dict, List, Optional, Sequenc...
BLINK-main
elq/biencoder/allennlp_span_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 os import json import logging import torch from tqdm import tqdm, trange from torch.utils.data import DataLoader, ...
BLINK-main
elq/biencoder/data_process.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 def batch_reshape_mask_left( input_t, selected, pad_idx=0, left_align_mask=None ): ...
BLINK-main
elq/biencoder/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 os import argparse import faiss import pickle import torch import json import sys import io import random import ti...
BLINK-main
elq/biencoder/train_biencoder.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 os import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from tqdm import tqdm from...
BLINK-main
elq/biencoder/biencoder.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 os import io import sys import json import torch import logging import numpy as np from collections import Ordere...
BLINK-main
elq/candidate_ranking/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. # # Provide an argument parser and default command line options for using ELQ. import argparse import importlib import os i...
BLINK-main
elq/common/params.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 import nn import torch def get_model_obj(model): model = model.module if hasattr(model, "module") else mo...
BLINK-main
elq/common/ranker_base.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. # """ FAISS-based index components. Original from https://github.com/facebookresearch/DPR/blob/master/dpr/indexer/faiss_ind...
BLINK-main
elq/index/faiss_indexer.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 numpy as np def entity_linking_tp_with_overlap(gold, predicted): """ Partially adopted from: https://gith...
BLINK-main
elq/vcg_utils/measures.py
import argparse import json import logging import os import random import time import torch from datetime import timedelta WORLDS = { 'american_football', 'doctor_who', 'fallout', 'final_fantasy', 'military', 'pro_wrestling', 'starwars', 'world_of_warcraft', 'coronation_street', ...
BLINK-main
examples/zeshel/create_BLINK_zeshel_data.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 DataLoader, RandomSampler, SequentialSampler, TensorDataset from elq.biencoder.b...
BLINK-main
scripts/generate_candidates.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 json import os import requests from bs4 import BeautifulSoup from tqdm import tqdm BEGIN_ENT_TOKEN = "[START_ENT]"...
BLINK-main
scripts/create_BLINK_benchmark_data.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 json import os import argparse parser = argparse.ArgumentParser() parser.add_argument('--path_to_s...
BLINK-main
scripts/merge_candidates.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 json import os import numpy as np import torch from elq.vcg_utils.measures import entity_linking_tp_with_overlap fr...
BLINK-main
scripts/tune_hyperparams_new.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import argparse import builtins import math import os import random import shutil import time import warnings import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distri...
asym-siam-main
main_moco.py
#!/usr/bin/env python # 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 builtins import math import os import random import shutil import time import w...
asym-siam-main
main_lincls.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
asym-siam-main
moco/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch import torch.nn as nn class MoCo(nn.Module): """ Build a MoCo model with: a query encoder, a key encoder, and a queue https://arxiv.org/abs/1911.05722 """ def __init__( self, base_encoder, ...
asym-siam-main
moco/builder.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from PIL import ImageFilter import random import numpy as np """ # --------------------------------------------------------------------------- # # ScaleMix # # ---------------------...
asym-siam-main
moco/loader.py
# Copyright 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. import argparse, json, os "...
clevr-dataset-gen-main
image_generation/collect_scenes.py
# Copyright 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. from __future__ import print...
clevr-dataset-gen-main
image_generation/render_images.py
# Copyright 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. import sys, random, os impor...
clevr-dataset-gen-main
image_generation/utils.py
# Copyright 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. import json, os, math from c...
clevr-dataset-gen-main
question_generation/question_engine.py
# Copyright 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. from __future__ import print...
clevr-dataset-gen-main
question_generation/generate_questions.py
# Copyright (c) Facebook, Inc. and its affiliates. import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="c3dm", # Replace with your own username version="1.0.0", author="Facebook AI Research", author_email="romansh@fb.com", description="""Co...
c3dm-main
setup.py
# Copyright (c) Facebook, Inc. and its affiliates. import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import os import torch from torch import nn as nn import torch.nn.functional as Fu import numpy as np from tools.utils import NumpySeedFix, auto_init_args from tools.vis_utils import get_visdom_...
c3dm-main
c3dm/c3dpo.py
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import inspect import copy import os import yaml import ast import numpy as np from tools.attr_dict import nested_attr_dict from tools.utils import auto_init_args def convert_to_stringval(cfg_,squeeze=None,stringify_vals=False): out = {} conv...
c3dm-main
c3dm/config.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from torch import nn from torch.nn import Parameter import torch.nn.functional as Fu import torchvision from torchvision import models from visdom import Visdom import numpy as np from tools.utils import auto_init_args import torchvision import collecti...
c3dm-main
c3dm/hypercolumnet.py
c3dm-main
c3dm/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy from functools import lru_cache import math import os import yaml import numpy as np import torch import torch.nn.functional as Fu from pytorch3d.renderer import cameras from pytorch3d.transforms import so3 from visdom import Visdom import c3dpo from h...
c3dm-main
c3dm/model.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import copy, os, sys, time import itertools as itt import yaml # torch imports import numpy as np import torch from dataset.batch_samplers import SceneBatchSampler from ...
c3dm-main
c3dm/experiment.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.nn.functional as Fu def image_meshgrid(bounds,resol): """ bounds in 3x2 resol in 3x1 """ # he,wi,de = resol # minw,maxw = bounds[0] # minh,maxh = bounds[1] # mind,maxd = bounds[2] axis = [ ((torch.arange(sz).float())/(sz-1))*(b[1]...
c3dm-main
c3dm/tools/pcl_unproject.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.nn.functional as Fu import numpy as np import collections import warnings def clamp_depth(X, min_depth): xy, depth = X[:,0:2], X[:,2:] depth = torch.clamp(depth, min_depth) return torch.cat((xy,depth), dim=1) def calc_ray_projection(X, Y...
c3dm-main
c3dm/tools/functions.py
# Copyright (c) Facebook, Inc. and its affiliates. from tools.utils import auto_init_args import torch import torch.nn.functional as Fu from torch.nn import Parameter from tools.utils import Timer class TensorAccumulator(torch.nn.Module): def __init__(self, db_size=30000, db_dim=3, perc_replace=0.01): super().__in...
c3dm-main
c3dm/tools/tensor_accumulator.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """Pretty-print tabular data.""" from __future__ import print_function from __future__ import unicode_literals from collections import namedtuple from platform import python_version_tuple import re import math if python_version_tuple() >= (...
c3dm-main
c3dm/tools/tabulate.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.nn.functional as Fu def find_camera_T(K, X, Y): n = X.shape[2] ba = X.shape[0] append1 = lambda x: \ torch.cat((x,x.new_ones(x.shape[0],1,x.shape[2])), dim=1) # projection rays r = torch.bmm(torch.inverse(K), a...
c3dm-main
c3dm/tools/test_orth2pers.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy def nested_attr_dict(dct): if type(dct) in (dict,AttrDict): dct = AttrDict(dct) for k,v in dct.items(): dct[k] = nested_attr_dict(v) return dct class AttrDict(dict): def __getattr__(self, name): if name in...
c3dm-main
c3dm/tools/attr_dict.py