text stringlengths 5 22M | id stringlengths 12 177 | metadata dict | __index_level_0__ int64 0 1.37k |
|---|---|---|---|
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import ctypes
libgcc_s = ctypes.CDLL('libgcc_s.so.1')
from collections import defaultdict
from concurrent.futures import as_completed, ProcessPoolExecutor
import logging
from src._execution import check_correctness, check_correctness_with_test_... | CodeT/CodeT/src/execution.py/0 | {
"file_path": "CodeT/CodeT/src/execution.py",
"repo_id": "CodeT",
"token_count": 1577
} | 218 |
import absl # Here to have a nice missing dependency error message early on
import nltk # Here to have a nice missing dependency error message early on
import numpy # Here to have a nice missing dependency error message early on
import six # Here to have a nice missing dependency error message early on
from rouge_s... | CodeT/DIVERSE/code/src/verifier_metrics.py/0 | {
"file_path": "CodeT/DIVERSE/code/src/verifier_metrics.py",
"repo_id": "CodeT",
"token_count": 1806
} | 219 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import tqdm
import itertools
from collections import defaultdict
from concurrent.futures import as_completed, ProcessPoolExecutor
from utils import Tools, FilePathBuilder, CONSTANTS
class BagOfWords:
def __init__(self, input_file):
... | CodeT/RepoCoder/build_vector.py/0 | {
"file_path": "CodeT/RepoCoder/build_vector.py",
"repo_id": "CodeT",
"token_count": 2906
} | 220 |
#!/bin/zsh
# This ZSH plugin reads the text from the current buffer
# and uses a Python script to complete the text.
create_completion() {
# Get the text typed until now.
text=${BUFFER}
completion=$(echo -n "$text" | $CODEX_CLI_PATH/src/codex_query.py)
# Add completion to the current buffer.
BUFF... | Codex-CLI/scripts/zsh_plugin.zsh/0 | {
"file_path": "Codex-CLI/scripts/zsh_plugin.zsh",
"repo_id": "Codex-CLI",
"token_count": 182
} | 221 |
[MESSAGES CONTROL]
# Use Python 3 style print for both support 2 and 3.
disable=superfluous-parens
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=8
| Cognitive-Face-Python/.pylintrc/0 | {
"file_path": "Cognitive-Face-Python/.pylintrc",
"repo_id": "Cognitive-Face-Python",
"token_count": 59
} | 222 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: large_person_group_person.py
Description: Large Person Group Person section of the Cognitive Face API.
"""
from . import util
def create(large_person_group_id, name, user_data=None):
"""Create a new person in a specified large person group. A newly created
... | Cognitive-Face-Python/cognitive_face/large_person_group_person.py/0 | {
"file_path": "Cognitive-Face-Python/cognitive_face/large_person_group_person.py",
"repo_id": "Cognitive-Face-Python",
"token_count": 1484
} | 223 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: util.py
Description: Shared utilities for the Python SDK of the Cognitive Face API.
"""
import os.path
import time
import requests
import cognitive_face as CF
DEFAULT_BASE_URL = os.environ['FACE_ENDPOINT']
TIME_SLEEP = 1
class CognitiveFaceException(Exceptio... | Cognitive-Face-Python/cognitive_face/util.py/0 | {
"file_path": "Cognitive-Face-Python/cognitive_face/util.py",
"repo_id": "Cognitive-Face-Python",
"token_count": 3029
} | 224 |
""" Official evaluation script for v1.1 of the SQuAD dataset.
Credit from: https://worksheets.codalab.org/rest/bundles/0xbcd57bee090b421c982906709c8c27e1/contents/blob/
"""
from __future__ import print_function
from collections import Counter
import string
import re
import argparse
import json
import sys
def normaliz... | ContextualSP/adaptershare/data_utils/squad_eval.py/0 | {
"file_path": "ContextualSP/adaptershare/data_utils/squad_eval.py",
"repo_id": "ContextualSP",
"token_count": 1832
} | 225 |
# coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import yaml
from data_utils.vocab import Vocabulary
from data_utils.task_def import TaskType, DataFormat, EncoderModelType
from data_utils.metrics import Metric
from mt_dnn.loss import LossCriterion
class TaskDef(dict):
def __init__(
self,
... | ContextualSP/adaptershare/experiments/exp_def.py/0 | {
"file_path": "ContextualSP/adaptershare/experiments/exp_def.py",
"repo_id": "ContextualSP",
"token_count": 2605
} | 226 |
#!/bin/bash
# Reuse of GLUE process script
# Copyright (c) Microsoft, Inc. and its affiliates.
#
# by Xiaodong Liu
# xiaodl@microsoft.com
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
# This script is used to cook SuperGLUE data in ... | ContextualSP/adaptershare/experiments/superglue/superglue_process.sh/0 | {
"file_path": "ContextualSP/adaptershare/experiments/superglue/superglue_process.sh",
"repo_id": "ContextualSP",
"token_count": 1422
} | 227 |
# coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import copy
import imp
import sys, os
import torch
import tasks
import math
import logging
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import *
from data_utils.utils impo... | ContextualSP/adaptershare/mt_dnn/adapter_diff_model.py/0 | {
"file_path": "ContextualSP/adaptershare/mt_dnn/adapter_diff_model.py",
"repo_id": "ContextualSP",
"token_count": 26955
} | 228 |
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from data_utils.task_def import TaskType
from module.san import SANClassifier
TASK_REGISTRY = {}
TASK_CLASS_NAMES = set()
class MTDNNTask:
def __init__(self, task_def):
self._task_def = task_def
def input_parse_labe... | ContextualSP/adaptershare/tasks/__init__.py/0 | {
"file_path": "ContextualSP/adaptershare/tasks/__init__.py",
"repo_id": "ContextualSP",
"token_count": 1963
} | 229 |
#!/bin/sh
tmpfile=$(mktemp)
head -n 2 $1 > ${tmpfile}
cat ${tmpfile} > $1
rm -f ${tmpfile}
| ContextualSP/adaptershare/tests/sample_data/input/my_head.sh/0 | {
"file_path": "ContextualSP/adaptershare/tests/sample_data/input/my_head.sh",
"repo_id": "ContextualSP",
"token_count": 43
} | 230 |
# coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import argparse
import json
import os
import random
from datetime import datetime
from pprint import pprint
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader, BatchSampler
from pretrained_models import *
# from tensorboardX im... | ContextualSP/adaptershare/train.py/0 | {
"file_path": "ContextualSP/adaptershare/train.py",
"repo_id": "ContextualSP",
"token_count": 14357
} | 231 |
import torch.nn as nn
from baseline.wtq_s2s.seq2seq import WTQSeq2SeqModel
from utils import *
from .spider_align import SpiderAlignmentModel
from .wtq_align import WTQAlignmentModel
_Model_mappings = {
'SpiderAlignmentModel':
{
'model': SpiderAlignmentModel,
'data_iter': load_spid... | ContextualSP/awakening_latent_grounding/models/model_utils.py/0 | {
"file_path": "ContextualSP/awakening_latent_grounding/models/model_utils.py",
"repo_id": "ContextualSP",
"token_count": 1654
} | 232 |
python train.py -model WTQAlignmentModel -bert bert-base-uncased \
-lr 3e-5 -train_bs 16 -alw linear_5-10 -num_epochs 20 \
--data_dir data/wtq_grounding \
--out_dir checkpoints/model_wtq | ContextualSP/awakening_latent_grounding/train_wtq_ground.sh/0 | {
"file_path": "ContextualSP/awakening_latent_grounding/train_wtq_ground.sh",
"repo_id": "ContextualSP",
"token_count": 83
} | 233 |
# Compositionality Generalization <img src="https://pytorch.org/assets/images/logo-dark.svg" height = "25" align=center />
This repository is the official implementation of our paper [Compositional Generalization by Learning Analytical Expressions](https://arxiv.org/pdf/2006.10627.pdf).
If you find our code useful fo... | ContextualSP/compositional_generalization/README.md/0 | {
"file_path": "ContextualSP/compositional_generalization/README.md",
"repo_id": "ContextualSP",
"token_count": 1084
} | 234 |
import math
import torch
import logging
from functools import partial
from torch.nn import functional as F
from tensorboardX import SummaryWriter
from torch.distributions.utils import lazy_property
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.distributions.categorical import Categorical as TorchCat... | ContextualSP/compositional_generalization/utils.py/0 | {
"file_path": "ContextualSP/compositional_generalization/utils.py",
"repo_id": "ContextualSP",
"token_count": 5853
} | 235 |
#!/usr/bin/env bash
export model_file=../checkpoints/run_canard
export config_file=../configs/canard.jsonnet
export train_data_path=../dataset/CANARD/train.txt
export validation_data_path=../dataset/CANARD/dev.txt
export pretrained_file=../glove/glove.6B.100d.txt
export seed=1
allennlp train -s ${model_file} ${config_f... | ContextualSP/incomplete_utterance_rewriting/src/train_canard.sh/0 | {
"file_path": "ContextualSP/incomplete_utterance_rewriting/src/train_canard.sh",
"repo_id": "ContextualSP",
"token_count": 232
} | 236 |
# coding: utf-8
import os
import json
import re
import pickle as pkl
import numpy as np
from src.utils.utils import lemma_token
from src.utils.link_util import find_alignment_by_rule, find_keyword_alignment_by_rule
from src.utils.utils import STOP_WORD_LIST
def jaccard_distance(word_list1, word_list2):
word_se... | ContextualSP/interactive_text_to_sql/src/components/question_generator.py/0 | {
"file_path": "ContextualSP/interactive_text_to_sql/src/components/question_generator.py",
"repo_id": "ContextualSP",
"token_count": 2675
} | 237 |
# coding: utf-8
import json
import os
import pickle as pkl
import nltk
from nltk.stem import WordNetLemmatizer
from tqdm import tqdm
from src.utils.utils import lemma_token
wordnet_lemmatizer = WordNetLemmatizer()
VALUE_FILTER = ['what', 'how', 'list', 'give', 'show', 'find', 'id', 'order', 'alse', 'when']
AGG = [... | ContextualSP/interactive_text_to_sql/src/utils/schema_linker.py/0 | {
"file_path": "ContextualSP/interactive_text_to_sql/src/utils/schema_linker.py",
"repo_id": "ContextualSP",
"token_count": 9130
} | 238 |
import itertools
import json
import logging
import os.path
from abc import ABCMeta, abstractmethod, abstractproperty
from collections import MutableMapping, Mapping, Sequence, Iterator
from contextlib import contextmanager
from sqlalchemy import MetaData
from sqlalchemy.engine.url import URL
from gtd.io import open_... | ContextualSP/lemon/executor/gtd/persist.py/0 | {
"file_path": "ContextualSP/lemon/executor/gtd/persist.py",
"repo_id": "ContextualSP",
"token_count": 15505
} | 239 |
from unittest import TestCase
from os.path import join
import pytest
from gtd.text import PhraseMatcher
from gtd.utils import FileMemoized, SimpleExecutor, as_batches, Failure, NestedDict, EqualityMixinSlots, \
memoize_with_key_fxn, DictMemoized
def test_as_batches():
items = [0, 1, 2, 3, 4, 5, 6]
assert... | ContextualSP/lemon/executor/gtd/tests/test_utils.py/0 | {
"file_path": "ContextualSP/lemon/executor/gtd/tests/test_utils.py",
"repo_id": "ContextualSP",
"token_count": 2716
} | 240 |
import logging
import sys
from abc import abstractproperty, ABCMeta
import numpy as np
import tensorflow as tf
from keras.layers import Dense
from numpy.testing import assert_array_almost_equal
from gtd.chrono import verboserate
from gtd.ml.framework import Feedable, Optimizable
from gtd.ml.model import Embedder, Mea... | ContextualSP/lemon/executor/strongsup/parse_model.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/parse_model.py",
"repo_id": "ContextualSP",
"token_count": 21417
} | 241 |
from strongsup.path_checker import PathChecker
class RLongPathChecker(PathChecker):
def __init__(self, config):
PathChecker.__init__(self, config)
self._max_stack_size = config.get('max_stack_size')
self._action_must_clear_beam = config.get('action_must_clear_beam')
def __call__(self... | ContextualSP/lemon/executor/strongsup/rlong/path_checker.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/rlong/path_checker.py",
"repo_id": "ContextualSP",
"token_count": 381
} | 242 |
# -*- coding: utf-8 -*-
import re
import unicodedata
def tsv_unescape(x):
"""Unescape strings in the TSV file.
Escaped characters include:
newline (0x10) -> backslash + n
vertical bar (0x7C) -> backslash + p
backslash (0x5C) -> backslash + backslash
Args:
x (str or unicode... | ContextualSP/lemon/executor/strongsup/tables/utils.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/tables/utils.py",
"repo_id": "ContextualSP",
"token_count": 1093
} | 243 |
import math
import numpy as np
import pytest
import tensorflow as tf
from numpy.testing import assert_array_almost_equal
from gtd.ml.framework import Feedable
from gtd.ml.model import TokenEmbedder
from gtd.ml.seq_batch import SequenceBatch
from gtd.ml.utils import guarantee_initialized_variables
from gtd.ml.vocab im... | ContextualSP/lemon/executor/strongsup/tests/test_parse_model.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/tests/test_parse_model.py",
"repo_id": "ContextualSP",
"token_count": 6157
} | 244 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import sys
from argparse import ArgumentParser
from fairseq_cli.train import cli_main as fairseq_train
from fairseq_cli.generate import cli_main as fairseq_generate
import logging
import shlex
import re
import os
sys.path.append('../')
# from mod... | ContextualSP/lemon/lemon/run_model_pretrain.py/0 | {
"file_path": "ContextualSP/lemon/lemon/run_model_pretrain.py",
"repo_id": "ContextualSP",
"token_count": 3752
} | 245 |
from allennlp_reasoning_explainqa.training.metrics.confusion_matrix import *
from allennlp_reasoning_explainqa.training.metrics.explanation_eval import *
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/eqasc/code/allennlp_reasoning_explainqa/training/metrics/__init__.py/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/eqasc/code/allennlp_reasoning_explainqa/training/metrics/__init__.py",
"repo_id": "ContextualSP",
"token_count": 50
} | 246 |
{"id":"8-343","answerKey":"B"}
{"id":"1129","answerKey":"A"}
{"id":"880","answerKey":"C"}
{"id":"7-999","answerKey":"C"}
{"id":"8-464","answerKey":"C"}
{"id":"9-794","answerKey":"C"}
{"id":"9-1163","answerKey":"C"}
{"id":"9-322","answerKey":"B"}
{"id":"7-1140","answerKey":"D"}
{"id":"7-903","answerKey":"B"}
{"id":"7-51... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/openbookqa/data/question-answers.jsonl/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/openbookqa/data/question-answers.jsonl",
"repo_id": "ContextualSP",
"token_count": 6310
} | 247 |
from typing import Dict, NamedTuple
class Metric(NamedTuple):
precision: float
recall: float
def F1(self):
if self.precision + self.recall == 0:
return 0.0
return 2 * self.precision * self.recall / (self.precision + self.recall)
def diagnostics(self) -> Dict[str, float]:... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/evaluation/metric.py/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/evaluation/metric.py",
"repo_id": "ContextualSP",
"token_count": 192
} | 248 |
## Test case: All ProPara answers
* answers.tsv is a sorted copy of the all answers of all [ProPara data sets](../../data/).
This is intended for exercising and checking Action File loading.
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/testfiles-0/README.md/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/testfiles-0/README.md",
"repo_id": "ContextualSP",
"token_count": 52
} | 249 |
import numpy as np
import pandas as pd
import json
import re
import string
import os
from tqdm import tqdm
import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--start', type=int)
parser.add_argument('--end', type=int)
parser.add_argument('--indicator_type')
def... | ContextualSP/logigan/corpus_construction/mlm_corpus/corpus_construction.py/0 | {
"file_path": "ContextualSP/logigan/corpus_construction/mlm_corpus/corpus_construction.py",
"repo_id": "ContextualSP",
"token_count": 1967
} | 250 |
import re
import os
from torchtext import data
from torchtext.data import Iterator, BucketIterator
from torchtext.vocab import GloVe
from torch.utils.data import Dataset, DataLoader
import torch
from collections import defaultdict
import string
from utils import Trie, Tree
class Dictionary:
def __init__(self, word... | ContextualSP/poset_decoding/sketch_prediction/data.py/0 | {
"file_path": "ContextualSP/poset_decoding/sketch_prediction/data.py",
"repo_id": "ContextualSP",
"token_count": 2389
} | 251 |
from .tuner import Tuner
from .tune import tune
| ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/auto/tuner/__init__.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/auto/tuner/__init__.py",
"repo_id": "ContextualSP",
"token_count": 15
} | 252 |
from . import toy
from . import wiki_qa
from . import embeddings
from . import snli
from . import quora_qp
from . import cfq
from pathlib import Path
def list_available():
return [p.name for p in Path(__file__).parent.iterdir()
if p.is_dir() and not p.name.startswith('_')]
| ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/datasets/__init__.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/datasets/__init__.py",
"repo_id": "ContextualSP",
"token_count": 108
} | 253 |
"""Parameters table class."""
import typing
import pandas as pd
import collections.abc
from matchzoo.engine.param import Param
from matchzoo.engine import hyper_spaces
class ParamTable(object):
"""
Parameter table class.
Example:
>>> params = ParamTable()
>>> params.add(Param('ham', 'P... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/engine/param_table.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/engine/param_table.py",
"repo_id": "ContextualSP",
"token_count": 2556
} | 254 |
"""An implementation of MatchPyramid Model."""
import typing
import torch
import torch.nn as nn
from matchzoo.engine.param_table import ParamTable
from matchzoo.engine.param import Param
from matchzoo.engine.base_model import BaseModel
from matchzoo.engine import hyper_spaces
from matchzoo.modules import Matching
fro... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/match_pyramid.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/match_pyramid.py",
"repo_id": "ContextualSP",
"token_count": 2362
} | 255 |
"""Spatial GRU module."""
import typing
import torch
import torch.nn as nn
import torch.nn.functional as F
from matchzoo.utils import parse_activation
class SpatialGRU(nn.Module):
"""
Spatial GRU Module.
:param channels: Number of word interaction tensor channels.
:param units: Number of SpatialGRU... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/modules/spatial_gru.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/modules/spatial_gru.py",
"repo_id": "ContextualSP",
"token_count": 2607
} | 256 |
from .unit import Unit
class NgramLetter(Unit):
"""
Process unit for n-letter generation.
Triletter is used in :class:`DSSMModel`.
This processor is expected to execute before `Vocab`
has been created.
Examples:
>>> triletter = NgramLetter()
>>> rv = triletter.transform(['hel... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/units/ngram_letter.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/units/ngram_letter.py",
"repo_id": "ContextualSP",
"token_count": 1008
} | 257 |
from .one_hot import one_hot
from .tensor_type import TensorType
from .list_recursive_subclasses import list_recursive_concrete_subclasses
from .parse import parse_loss, parse_activation, parse_metric, parse_optimizer
from .average_meter import AverageMeter
from .timer import Timer
from .early_stopping import EarlyStop... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/utils/__init__.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/utils/__init__.py",
"repo_id": "ContextualSP",
"token_count": 107
} | 258 |
import matchzoo as mz
from matchzoo import preprocessors
from matchzoo.dataloader import Dataset
def test_dataset():
data_pack = mz.datasets.toy.load_data('train', task='ranking')
preprocessor = mz.preprocessors.BasicPreprocessor()
data_processed = preprocessor.fit_transform(data_pack)
dataset_point ... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/dataloader/test_dataset.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/dataloader/test_dataset.py",
"repo_id": "ContextualSP",
"token_count": 560
} | 259 |
<jupyter_start><jupyter_code>%run init.ipynb
preprocessor = mz.models.Bert.get_default_preprocessor()
train_pack_processed = preprocessor.transform(train_pack_raw)
dev_pack_processed = preprocessor.transform(dev_pack_raw)
test_pack_processed = preprocessor.transform(test_pack_raw)
trainset = mz.dataloader.Dataset(
... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/classification/bert.ipynb/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/classification/bert.ipynb",
"repo_id": "ContextualSP",
"token_count": 740
} | 260 |
<jupyter_start><jupyter_code>import torch
import numpy as np
import pandas as pd
import matchzoo as mz
print('matchzoo version', mz.__version__)
ranking_task = mz.tasks.Ranking(losses=mz.losses.RankCrossEntropyLoss(num_neg=1))
ranking_task.metrics = [
mz.metrics.NormalizedDiscountedCumulativeGain(k=3),
mz.metri... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/match_pyramid.ipynb/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/match_pyramid.ipynb",
"repo_id": "ContextualSP",
"token_count": 1044
} | 261 |
#!/usr/bin/env bash
export seed=1
export config_file=train_configs/concat.none.jsonnet
export model_file=checkpoints_sparc/sparc_concat_none_model
export tables_file=dataset_sparc/tables.json
export database_path=dataset_sparc/database
export dataset_path=dataset_sparc
export train_data_path=dataset_sparc/train.json
ex... | ContextualSP/semantic_parsing_in_context/bash_files/linux/train_sparc.bash/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/bash_files/linux/train_sparc.bash",
"repo_id": "ContextualSP",
"token_count": 374
} | 262 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import List, Tuple, Dict
from allennlp.common.util import pad_sequence_to_length
from context.converter import SQLConverter
from context.db_context import SparcDBContext
from context.grammar import Grammar, Action, C, T, Segment
... | ContextualSP/semantic_parsing_in_context/context/world.py/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/context/world.py",
"repo_id": "ContextualSP",
"token_count": 3493
} | 263 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import List, Optional
import torch
from allennlp.nn import util
class RnnStatelet:
"""
This class keeps track of all of decoder-RNN-related variables that you need during decoding.
This includes things like the current ... | ContextualSP/semantic_parsing_in_context/models/states_machine/rnn_statelet.py/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/models/states_machine/rnn_statelet.py",
"repo_id": "ContextualSP",
"token_count": 1688
} | 264 |
import argparse
import stanza
from unisar.api import UnisarAPI
class Interactive(object):
def __init__(self, Unisar: UnisarAPI):
self.unisar = Unisar
def ask_any_question(self, question, db_id):
results = self.unisar.infer_query(question, db_id)
print('input:', results['slml_questio... | ContextualSP/unified_parser_text_to_sql/interactive.py/0 | {
"file_path": "ContextualSP/unified_parser_text_to_sql/interactive.py",
"repo_id": "ContextualSP",
"token_count": 782
} | 265 |
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from model.module.Linear_super import LinearSuper
from model.module.layernorm_super import LayerNormSuper
from model.module.multihead_super import AttentionSuper
from model.module.embedding_super import PatchembedSuper
from model.utils impo... | Cream/AutoFormer/model/supernet_transformer.py/0 | {
"file_path": "Cream/AutoFormer/model/supernet_transformer.py",
"repo_id": "Cream",
"token_count": 6478
} | 266 |
# flake8: noqa
from .arraymisc import *
from .utils import *
from .fileio import *
from .opencv_info import *
from .image import *
from .video import *
from .visualization import *
from .version import __version__
# The following modules are not imported to this level, so mmcv may be used
# without PyTorch.
# - runner
... | Cream/CDARTS/CDARTS_detection/mmcv/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/__init__.py",
"repo_id": "Cream",
"token_count": 97
} | 267 |
def list_from_file(filename, prefix='', offset=0, max_num=0):
"""Load a text file and parse the content as a list of strings.
Args:
filename (str): Filename.
prefix (str): The prefix to be inserted to the begining of each item.
offset (int): The offset of lines.
max_num (int): T... | Cream/CDARTS/CDARTS_detection/mmcv/fileio/parse.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/fileio/parse.py",
"repo_id": "Cream",
"token_count": 685
} | 268 |
from .runner import Runner
from .log_buffer import LogBuffer
from .dist_utils import get_dist_info, init_dist, master_only
from .hooks import (Hook, CheckpointHook, ClosureHook, LrUpdaterHook,
OptimizerHook, OptimizerArchHook, IterTimerHook, DistSamplerSeedHook,
LoggerHook, TextL... | Cream/CDARTS/CDARTS_detection/mmcv/runner/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/__init__.py",
"repo_id": "Cream",
"token_count": 521
} | 269 |
from .hook import Hook
class DistSamplerSeedHook(Hook):
def before_epoch(self, runner):
runner.data_loader.sampler.set_epoch(runner.epoch)
| Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/sampler_seed.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/sampler_seed.py",
"repo_id": "Cream",
"token_count": 61
} | 270 |
from .version import __version__, short_version
__all__ = ['__version__', 'short_version']
| Cream/CDARTS/CDARTS_detection/mmdet/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/__init__.py",
"repo_id": "Cream",
"token_count": 28
} | 271 |
import torch
from .base_assigner import BaseAssigner
from .assign_result import AssignResult
from ..geometry import bbox_overlaps
class MaxIoUAssigner(BaseAssigner):
"""Assign a corresponding gt bbox or background to each bbox.
Each proposals will be assigned with `-1`, `0`, or a positive integer
indica... | Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/max_iou_assigner.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/max_iou_assigner.py",
"repo_id": "Cream",
"token_count": 3164
} | 272 |
import mmcv
import numpy as np
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
from .recall import eval_recalls
def coco_eval(result_files, result_types, coco, max_dets=(100, 300, 1000)):
for res_type in result_types:
assert res_type in [
'proposal', 'proposal_fast... | Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/coco_utils.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/coco_utils.py",
"repo_id": "Cream",
"token_count": 3202
} | 273 |
from functools import partial
import mmcv
import numpy as np
from six.moves import map, zip
def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True):
num_imgs = tensor.size(0)
mean = np.array(mean, dtype=np.float32)
std = np.array(std, dtype=np.float32)
imgs = []
for img_id in range(nu... | Cream/CDARTS/CDARTS_detection/mmdet/core/utils/misc.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/utils/misc.py",
"repo_id": "Cream",
"token_count": 500
} | 274 |
from mmdet.utils import Registry
DATASETS = Registry('dataset')
PIPELINES = Registry('pipeline')
| Cream/CDARTS/CDARTS_detection/mmdet/datasets/registry.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/datasets/registry.py",
"repo_id": "Cream",
"token_count": 34
} | 275 |
from .resnet import ResNet, make_res_layer
from .resnext import ResNeXt
from .ssd_vgg import SSDVGG
from .hrnet import HRNet
from .mobilenetv2 import MobileNetV2
from .detnas import DetNas
from .fbnet import FBNet
from .mnasnet import MnasNet
from .mobilenetv3 import SSDMobilenetV3
from .efficientnet import SSDEFFB0
_... | Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/__init__.py",
"repo_id": "Cream",
"token_count": 181
} | 276 |
import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import (VGG, xavier_init, constant_init, kaiming_init,
normal_init)
from mmcv.runner import load_checkpoint
from ..registry import BACKBONES
@BACKBONES.register_module
class SSDVGG(VGG):
extra_s... | Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/ssd_vgg.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/ssd_vgg.py",
"repo_id": "Cream",
"token_count": 2468
} | 277 |
from .two_stage import TwoStageDetector
from ..registry import DETECTORS
@DETECTORS.register_module
class FasterRCNN(TwoStageDetector):
def __init__(self,
backbone,
rpn_head,
bbox_roi_extractor,
bbox_head,
train_cfg,
... | Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/faster_rcnn.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/faster_rcnn.py",
"repo_id": "Cream",
"token_count": 575
} | 278 |
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..registry import LOSSES
def _expand_binary_labels(labels, label_weights, label_channels):
bin_labels = labels.new_full((labels.size(0), label_channels), 0)
inds = torch.nonzero(labels >= 1).squeeze()
if inds.numel() > 0:
bin... | Cream/CDARTS/CDARTS_detection/mmdet/models/losses/ghm_loss.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/losses/ghm_loss.py",
"repo_id": "Cream",
"token_count": 2855
} | 279 |
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import xavier_init
from ..plugins import NonLocal2D
from ..registry import NECKS
from ..utils import ConvModule
@NECKS.register_module
class BFP(nn.Module):
"""BFP (Balanced Feature Pyrmamids)
BFP takes multi-level features as inputs and ga... | Cream/CDARTS/CDARTS_detection/mmdet/models/necks/bfp.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/necks/bfp.py",
"repo_id": "Cream",
"token_count": 1712
} | 280 |
import torch.nn as nn
import torch.nn.functional as F
def conv_ws_2d(input,
weight,
bias=None,
stride=1,
padding=0,
dilation=1,
groups=1,
eps=1e-5):
c_in = weight.size(0)
weight_flat = weight.view(c_in, -1... | Cream/CDARTS/CDARTS_detection/mmdet/models/utils/conv_ws.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/utils/conv_ws.py",
"repo_id": "Cream",
"token_count": 786
} | 281 |
// modify from
// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c
// based on
// author: Charles Shang
// https://github.com/torch/cunn/blob/master/lib/THCUNN/generic/SpatialConvolutionMM.cu
#include <torch/extension.h>
#include <cmath>
#include... | Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda.cpp/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda.cpp",
"repo_id": "Cream",
"token_count": 1451
} | 282 |
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
#include <torch/extension.h>
#define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")
at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh);
at::Tensor nms(const at::Tensor& dets, const float threshold... | Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cuda.cpp/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cuda.cpp",
"repo_id": "Cream",
"token_count": 236
} | 283 |
import torch
from torch.autograd import Function
from .. import roi_pool_cuda
class RoIPoolFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale):
if isinstance(out_size, int):
out_h = out_size
out_w = out_size
elif isinstance(out_... | Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/roi_pool.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/roi_pool.py",
"repo_id": "Cream",
"token_count": 886
} | 284 |
import os.path as osp
import subprocess
import sys
from collections import defaultdict
import cv2
import mmcv
import torch
import torchvision
import mmdet
def collect_env():
env_info = {}
env_info['sys.platform'] = sys.platform
env_info['Python'] = sys.version.replace('\n', '')
cuda_available = tor... | Cream/CDARTS/CDARTS_detection/mmdet/utils/collect_env.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/utils/collect_env.py",
"repo_id": "Cream",
"token_count": 855
} | 285 |
import argparse
import os
import os.path as osp
import pickle
import shutil
import tempfile
import mmcv
import torch
import torch.distributed as dist
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import get_dist_info, init_dist, load_checkpoint
from mmdet.core import wrap_fp16_m... | Cream/CDARTS/CDARTS_detection/tools/test.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/tools/test.py",
"repo_id": "Cream",
"token_count": 4690
} | 286 |
from __future__ import print_function, division
import os
from PIL import Image
import numpy as np
from torch.utils.data import Dataset
from torchvision import transforms
from dataloaders import custom_transforms as tr
class VOCSegmentation(Dataset):
"""
PascalVoc dataset
"""
NUM_CLASSES = 21
def ... | Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/pascal.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/pascal.py",
"repo_id": "Cream",
"token_count": 2151
} | 287 |
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Create by Bin Xiao (Bin.Xiao@microsoft.com)
# Modified by Ke Sun (sunk@mail.ustc.edu.cn), Rainbowsecret (yuyua@microsoft.com)
# -------------------------------------------------... | Cream/CDARTS/CDARTS_segmentation/segmentation/config/hrnet_config.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/config/hrnet_config.py",
"repo_id": "Cream",
"token_count": 1819
} | 288 |
from .semantic import SemanticEvaluator
from .instance import CityscapesInstanceEvaluator
from .panoptic import CityscapesPanopticEvaluator
from .coco_instance import COCOInstanceEvaluator
from .coco_panoptic import COCOPanopticEvaluator
| Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/__init__.py",
"repo_id": "Cream",
"token_count": 78
} | 289 |
# ------------------------------------------------------------------------------
# Common modules.
# Written by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
from functools import partial
import torch
from torch import nn
from torch.nn import funct... | Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/conv_module.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/conv_module.py",
"repo_id": "Cream",
"token_count": 1127
} | 290 |
# ------------------------------------------------------------------------------
# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/solver/build.py
# Modified by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
from enum... | Cream/CDARTS/CDARTS_segmentation/segmentation/solver/build.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/solver/build.py",
"repo_id": "Cream",
"token_count": 3020
} | 291 |
import numpy as np
np.seterr(divide='ignore', invalid='ignore')
# voc cityscapes metric
def hist_info(n_cl, pred, gt):
assert (pred.shape == gt.shape)
k = (gt >= 0) & (gt < n_cl)
labeled = np.sum(k)
correct = np.sum((pred[k] == gt[k]))
return np.bincount(n_cl * gt[k].astype(int) + pred[k].astype... | Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/metric.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/metric.py",
"repo_id": "Cream",
"token_count": 1221
} | 292 |
import torch
import math
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from torch import nn, einsum
from einops import rearrange
def pair(x):
return (x, x) if not isinstance(x, tuple) else x
def expand_dim(t, dim, k):
t = t.unsqueeze(dim = di... | Cream/CDARTS/CDARTS_segmentation/train/att_sa.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/train/att_sa.py",
"repo_id": "Cream",
"token_count": 3832
} | 293 |
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Modified by Xiyang for effortlessly launching on Azure ML
"""
r"""
`torch.distributed.launch` is a module that spawns up multiple distributed
training processes on each of the training nodes.
The utility can be used for single-no... | Cream/CDARTS/CDARTS_segmentation/train/launch.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/train/launch.py",
"repo_id": "Cream",
"token_count": 4453
} | 294 |
10/22 12:30:18 AM |
10/22 12:30:18 AM | Parameters:
10/22 12:30:18 AM | ALPHA_LR=0.0006
10/22 12:30:18 AM | ALPHA_WEIGHT_DECAY=0.001
10/22 12:30:18 AM | AUX_WEIGHT=0.4
10/22 12:30:18 AM | BATCH_SIZE=128
10/22 12:30:18 AM | CELLS_NUM=3
10/22 12:30:18 AM | CLEAN_ARCH=False
10/22 12:30:18 AM | CUTOUT_LENGTH=16
10/22 12:3... | Cream/CDARTS/benchmark201/search/cifar10-search/cifar10-search.log/0 | {
"file_path": "Cream/CDARTS/benchmark201/search/cifar10-search/cifar10-search.log",
"repo_id": "Cream",
"token_count": 235681
} | 295 |
Hiring research interns for neural architecture search projects: houwen.peng@microsoft.com
# Cream of the Crop: Distilling Prioritized Paths For One-Shot Neural Architecture Search
This is an official implementation for our Cream NAS work presented in NeurIPS'20.
**[[Paper]](https://papers.nips.cc/paper/2020/file/d0... | Cream/Cream/README.md/0 | {
"file_path": "Cream/Cream/README.md",
"repo_id": "Cream",
"token_count": 3082
} | 296 |
AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: 'Supernet_Training'
RESUME_PATH: './experiments/workspace/train/resume.pth.tar'
SAVE_PATH: './experiments/workspace/train'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
... | Cream/Cream/experiments/configs/train/train.yaml/0 | {
"file_path": "Cream/Cream/experiments/configs/train/train.yaml",
"repo_id": "Cream",
"token_count": 461
} | 297 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Written by Hao Du and Houwen Peng
# email: haodu8-c@my.cityu.edu.hk and houwen.peng@microsoft.com
from lib.utils.builder_util import *
from lib.utils.search_structure_supernet import *
from lib.models.builders.build_supernet import *
from lib.u... | Cream/Cream/lib/models/structures/supernet.py/0 | {
"file_path": "Cream/Cream/lib/models/structures/supernet.py",
"repo_id": "Cream",
"token_count": 3647
} | 298 |
"""
Misc functions, including distributed helpers and model loaders
Also include a model loader specified for finetuning EfficientViT
"""
import io
import os
import time
from collections import defaultdict, deque
import datetime
import torch
import torch.distributed as dist
class SmoothedValue(object):
"""Track ... | Cream/EfficientViT/classification/utils.py/0 | {
"file_path": "Cream/EfficientViT/classification/utils.py",
"repo_id": "Cream",
"token_count": 4480
} | 299 |
# model settings
model = dict(
type='FastRCNN',
pretrained='torchvision://resnet50',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
... | Cream/EfficientViT/downstream/configs/_base_/models/fast_rcnn_r50_fpn.py/0 | {
"file_path": "Cream/EfficientViT/downstream/configs/_base_/models/fast_rcnn_r50_fpn.py",
"repo_id": "Cream",
"token_count": 1210
} | 300 |
import argparse
import copy
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
import torch.distributed as dist
from mmcv import Config, DictAction
from mmcv.runner import get_dist_info, init_dist
from mmcv.utils import get_git_hash
from mmdet import __version__
from mmdet.apis impor... | Cream/EfficientViT/downstream/train.py/0 | {
"file_path": "Cream/EfficientViT/downstream/train.py",
"repo_id": "Cream",
"token_count": 3905
} | 301 |
MODEL:
TYPE: swin_minivit_distill
NAME: swin_small_patch4_window7_224_minivit
DROP_PATH_RATE: 0.1
SWIN:
EMBED_DIM: 96
DEPTHS: [ 2, 2, 18, 2 ]
NUM_HEADS: [ 3, 6, 12, 24 ]
WINDOW_SIZE: 7
MINIVIT:
SEPARATE_LAYERNUM_LIST: [1, 1, 9, 1] | Cream/MiniViT/Mini-Swin/configs/swin_small_patch4_window7_224_minivit_sharenum2.yaml/0 | {
"file_path": "Cream/MiniViT/Mini-Swin/configs/swin_small_patch4_window7_224_minivit_sharenum2.yaml",
"repo_id": "Cream",
"token_count": 140
} | 302 |
# TinyCLIP Training
In this document, we introduce ***auto weight inheritance*** and ***manual weight inheritance method*** to train a TinyCLIP model with the proposed ***cross-modalities distillation***.
:star: **[Notice]** Please replace the training data loader with the one loading LAION-400M or YFCC-15M.
Refere... | Cream/TinyCLIP/docs/PRETRAINING.md/0 | {
"file_path": "Cream/TinyCLIP/docs/PRETRAINING.md",
"repo_id": "Cream",
"token_count": 426
} | 303 |
import torch
import torch.distributed.nn
from torch import distributed as dist, nn as nn
from torch.nn import functional as F
from open_clip.loss import gather_features, gather_feature
from contextlib import nullcontext
import numpy as np
class ClipSoftLoss(nn.Module):
def __init__(
self,
... | Cream/TinyCLIP/src/open_clip/clip_soft_loss.py/0 | {
"file_path": "Cream/TinyCLIP/src/open_clip/clip_soft_loss.py",
"repo_id": "Cream",
"token_count": 1652
} | 304 |
""" OpenAI pretrained model functions
Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI.
"""
import os
import warnings
from typing import Union, List
import torch
from .model import build_model_from_openai_state_dict
from .pretrained import get_pretrained_url, list_pretr... | Cream/TinyCLIP/src/open_clip/openai.py/0 | {
"file_path": "Cream/TinyCLIP/src/open_clip/openai.py",
"repo_id": "Cream",
"token_count": 2042
} | 305 |
from __future__ import division
import torch
import math
import sys
from .aug_random import random
from PIL import Image
try:
import accimage
except ImportError:
accimage = None
import numpy as np
import numbers
import types
import collections
import warnings
from torchvision.transforms import functional as F
... | Cream/TinyViT/data/augmentation/aug_tv_transforms.py/0 | {
"file_path": "Cream/TinyViT/data/augmentation/aug_tv_transforms.py",
"repo_id": "Cream",
"token_count": 17077
} | 306 |
""" A dataset parser that reads images from folders
Folders are scannerd recursively to find image files. Labels are based
on the folder hierarchy, just leaf folders by default.
Hacked together by / Copyright 2020 Ross Wightman
"""
import os
from timm.utils.misc import natural_key
from .parser import Parser
from .c... | Cream/TinyViT/data/augmentation/parsers/parser_image_folder.py/0 | {
"file_path": "Cream/TinyViT/data/augmentation/parsers/parser_image_folder.py",
"repo_id": "Cream",
"token_count": 1087
} | 307 |
# Training TinyViT
In this document, we introduce how to pretrain TinyViT with the proposed fast pretraining distillation.
Note: If the GPU memory is not enough to fit the batch size, you can use `Gradient accumulation steps` by adding the argument `--accumulation-steps <acc_steps>`. For example, the accumulated batc... | Cream/TinyViT/docs/TRAINING.md/0 | {
"file_path": "Cream/TinyViT/docs/TRAINING.md",
"repo_id": "Cream",
"token_count": 986
} | 308 |
# ---------------------------------------------------------------
# TinyViT Utils
# Copyright (c) 2022 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Based on the code: Swin Transformer
# (https://github.com/microsoft/swin-transformer)
# Add `LRSchedulerWrapper` and `divide_param_groups_by_lr_... | Cream/TinyViT/tinyvit_utils.py/0 | {
"file_path": "Cream/TinyViT/tinyvit_utils.py",
"repo_id": "Cream",
"token_count": 2402
} | 309 |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Modules to compute the matching cost and solve the corresponding LSAP.
"""
import torch
from scipy.optimize import linear_sum_assignment
from torch import nn
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou
class HungarianMatc... | Cream/iRPE/DETR-with-iRPE/models/matcher.py/0 | {
"file_path": "Cream/iRPE/DETR-with-iRPE/models/matcher.py",
"repo_id": "Cream",
"token_count": 1675
} | 310 |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Utilities for bounding box manipulation and GIoU.
"""
import torch
from torchvision.ops.boxes import box_area
def box_cxcywh_to_xyxy(x):
x_c, y_c, w, h = x.unbind(-1)
b = [(x_c - 0.5 * w), (y_c - 0.5 * h),
(x_c + 0.5 * w), (y_... | Cream/iRPE/DETR-with-iRPE/util/box_ops.py/0 | {
"file_path": "Cream/iRPE/DETR-with-iRPE/util/box_ops.py",
"repo_id": "Cream",
"token_count": 1193
} | 311 |
_model_entrypoints = {}
def register_model(fn):
module_name_split = fn.__module__.split('.')
model_name = module_name_split[-1]
_model_entrypoints[model_name] = fn
return fn
def model_entrypoints(model_name):
return _model_entrypoints[model_name]
def is_model(model_name):
return model_na... | CvT/lib/models/registry.py/0 | {
"file_path": "CvT/lib/models/registry.py",
"repo_id": "CvT",
"token_count": 128
} | 312 |
VALUE_LOWER_BOUND = -1.0e100
VALUE_UPPER_BOUND = 1.0e100
MIN_POINTS = 12
| anomalydetector/aml_component/constants.py/0 | {
"file_path": "anomalydetector/aml_component/constants.py",
"repo_id": "anomalydetector",
"token_count": 37
} | 313 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from archai.api.dataset_provider import DatasetProvider
__all__ = ['DatasetProvider']
| archai/archai/api/__init__.py/0 | {
"file_path": "archai/archai/api/__init__.py",
"repo_id": "archai",
"token_count": 48
} | 314 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import time
import argparse
import json
import os
from typing import List, Dict
from azure.ai.ml.identity import AzureMLOnBehalfOfCredential
from azure.identity import DefaultAzureCredential
from archai.common.store import ArchaiStore
from azure.a... | archai/archai/common/monitor.py/0 | {
"file_path": "archai/archai/common/monitor.py",
"repo_id": "archai",
"token_count": 3979
} | 315 |
from pathlib import Path
from typing import Callable, Optional, Tuple
from overrides import overrides
import torch
import torchvision.transforms.functional as F
from torchvision.io import read_image
from archai.api.dataset_provider import DatasetProvider
from archai.common.utils import download_and_extract_zip
clas... | archai/archai/datasets/cv/face_synthetics.py/0 | {
"file_path": "archai/archai/datasets/cv/face_synthetics.py",
"repo_id": "archai",
"token_count": 1953
} | 316 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import json
import os
import pickle
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Union
import numpy as np
import... | archai/archai/datasets/nlp/fast_hf_dataset_provider.py/0 | {
"file_path": "archai/archai/datasets/nlp/fast_hf_dataset_provider.py",
"repo_id": "archai",
"token_count": 8021
} | 317 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.