text stringlengths 5 22M | id stringlengths 12 177 | metadata dict | __index_level_0__ int64 0 1.37k |
|---|---|---|---|
import torch
from torch import nn
from modules.BinaryTreeLstmCell import BinaryTreeLstmCell
from modules.LstmRnn import LstmRnn
class BinaryTreeBasedModule(nn.Module):
no_transformation = "no_transformation"
lstm_transformation = "lstm_transformation"
bi_lstm_transformation = "bi_lstm_transformation"
... | ContextualSP/compositional_generalization/modules/BinaryTreeBasedModule.py/0 | {
"file_path": "ContextualSP/compositional_generalization/modules/BinaryTreeBasedModule.py",
"repo_id": "ContextualSP",
"token_count": 1832
} | 239 |
{
"random_seed": 42,
"numpy_seed": 42,
"pytorch_seed": 42,
"dataset_reader": {
"type": "rewrite",
"lazy": false,
"super_mode": "before",
"joint_encoding": true,
"extra_stop_words": [
"'s",
"besides",
"the",
"in",
"of"
]
},
"model": {
"type": "rewrite",
"word_embedder": {
"tokens"... | ContextualSP/incomplete_utterance_rewriting/configs/canard.jsonnet/0 | {
"file_path": "ContextualSP/incomplete_utterance_rewriting/configs/canard.jsonnet",
"repo_id": "ContextualSP",
"token_count": 655
} | 240 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import json
import random
import re
import jieba
import spacy
from tqdm import tqdm
random.seed(42)
nlp_en = spacy.load('en_core_web_sm')
def is_all_chinese(word):
# identify whether all chinese characters
for _char in... | ContextualSP/incomplete_utterance_rewriting/preprocess.py/0 | {
"file_path": "ContextualSP/incomplete_utterance_rewriting/preprocess.py",
"repo_id": "ContextualSP",
"token_count": 4424
} | 241 |
#!/usr/bin/env bash
export model_file=../checkpoints/run_rewrite_bert_
export config_file=../configs/rewrite_bert.jsonnet
export train_data_path=../dataset/Rewrite/train.txt
export validation_data_path=../dataset/Rewrite/dev.txt
export seed=1
allennlp train -s ${model_file} ${config_file} \
--include-package data_reade... | ContextualSP/incomplete_utterance_rewriting/src/train_rewrite_bert.sh/0 | {
"file_path": "ContextualSP/incomplete_utterance_rewriting/src/train_rewrite_bert.sh",
"repo_id": "ContextualSP",
"token_count": 191
} | 242 |
from typing import Dict, Set
from context.db_context import SparcDBContext
from context.utils import Table, TableColumn
Keywords = ['limit', 'des', 'asc', 'and', 'or', 'sum', 'min', 'max', 'avg', 'none', '=', '!=', '<', '>', '<=', '>=',
'between', 'like', 'not_like', 'in', 'not_in', 'intersect', 'union', '... | ContextualSP/interactive_text_to_sql/src/context/grammar.py/0 | {
"file_path": "ContextualSP/interactive_text_to_sql/src/context/grammar.py",
"repo_id": "ContextualSP",
"token_count": 5484
} | 243 |
# coding: utf-8
import json
all_examples = {
'trian': json.load(open('data/spider/train_spider.json', 'r', encoding='utf-8')),
'dev': json.load(open('data/spider/dev.json', 'r', encoding='utf-8'))
}
def search_for_id(question, split='dev'):
examples = all_examples[split]
for idx, example in enumerat... | ContextualSP/interactive_text_to_sql/src/utils/tools.py/0 | {
"file_path": "ContextualSP/interactive_text_to_sql/src/utils/tools.py",
"repo_id": "ContextualSP",
"token_count": 214
} | 244 |
from collections import defaultdict, Counter, deque
import numpy as np
import random
from gtd import utils
# defines whether an edge is inverted or not
inverted = lambda r: r[:2] == '**'
invert = lambda r: r[2:] if inverted(r) else '**' + r
class Graph(object):
def __init__(self, triples):
self.triples... | ContextualSP/lemon/executor/gtd/graph.py/0 | {
"file_path": "ContextualSP/lemon/executor/gtd/graph.py",
"repo_id": "ContextualSP",
"token_count": 3785
} | 245 |
from abc import ABCMeta, abstractmethod
import numpy as np
from strongsup.utils import softmax_with_alpha_beta
from strongsup.value import check_denotation
from strongsup.value_function import ConstantValueFunction
class CaseWeighter(object, metaclass=ABCMeta):
@abstractmethod
def __call__(self, paths, exa... | ContextualSP/lemon/executor/strongsup/case_weighter.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/case_weighter.py",
"repo_id": "ContextualSP",
"token_count": 2087
} | 246 |
from strongsup.value import Value
class RLongStateValue(Value):
"""Value based on RLongState."""
def __init__(self, state):
self._state = state
def __repr__(self):
return repr(self._state)
@property
def state(self):
return self._state
def __eq__(self, other):
... | ContextualSP/lemon/executor/strongsup/rlong/value.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/rlong/value.py",
"repo_id": "ContextualSP",
"token_count": 197
} | 247 |
import copy
import os
import pytest
import shutil
from strongsup.results.tracker import LeafTracker, TopLevelTracker
from strongsup.results.entry import Entry, ExperimentType
from strongsup.results.result_value import ResultValue
class TestTracker(object):
@pytest.fixture
def filters(self):
return ["m... | ContextualSP/lemon/executor/strongsup/tests/results/test_tracker.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/tests/results/test_tracker.py",
"repo_id": "ContextualSP",
"token_count": 5367
} | 248 |
import copy
import random
from collections import MutableMapping
import numpy as np
import tensorflow as tf
# End of utterance token
EOU = '<EOU>'
def epsilon_greedy_sample(choices, num_to_sample, epsilon=0.05):
"""Samples without replacement num_to_sample choices from choices
where the ith choice is choic... | ContextualSP/lemon/executor/strongsup/utils.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/utils.py",
"repo_id": "ContextualSP",
"token_count": 1578
} | 249 |
This repository contains tools for generating datasets and evaluating predictions for the following [AI2 Leaderboards](https://leaderboard.allenai.org/):
* [ARC (AI2 Reasoning Challenge)](arc/)
* [OpenBook QA](openbookqa/)
* [ProPara](propara/)
* [QASC](qasc/)
* [SciTail](scitail/)
* [eQASC](eqasc/)
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/README.md/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/README.md",
"repo_id": "ContextualSP",
"token_count": 101
} | 250 |
{ "id": "question1", "answerKey": "C" }
{ "id": "question2", "answerKey": "B" }
{ "id": "question3", "answerKey": "C" }
{ "id": "question4", "answerKey": "D" }
{ "id": "question5", "answerKey": "D" }
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/arc/evaluator/questions.jsonl/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/arc/evaluator/questions.jsonl",
"repo_id": "ContextualSP",
"token_count": 85
} | 251 |
{"score": 0.2023383378982544, "chain_id": "3C44YUNSI1OBFBB8D36GODNOZN9DPA_1_1"}
{"score": 0.5158032774925232, "chain_id": "3C44YUNSI1OBFBB8D36GODNOZN9DPA_1_2"}
{"score": 0.17925743758678436, "chain_id": "3C44YUNSI1OBFBB8D36GODNOZN9DPA_1_5"}
{"score": 0.8793290853500366, "chain_id": "3C44YUNSI1OBFBB8D36GODNOZN9DPA_1_7"}... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/eqasc/code/predictions/grc.test.predict/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/eqasc/code/predictions/grc.test.predict",
"repo_id": "ContextualSP",
"token_count": 426542
} | 252 |
from collections import OrderedDict, defaultdict
from typing import NamedTuple, Dict, List
from errors import corrupted_action_file
from process.constants import LOCATION_UNKNOWN, NO_LOCATION, NO_ACTION, CREATE, MOVE, DESTROY
from process import ProcessSummary, Process
def _accumulate_action(locations, actions, num_... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/process/action_file.py/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/process/action_file.py",
"repo_id": "ContextualSP",
"token_count": 4746
} | 253 |
{ "id": "P1", "gold_label": "E" }
{ "id": "P2", "gold_label": "E" }
{ "id": "P3", "gold_label": "N" }
{ "id": "P4", "gold_label": "N" }
{ "id": "P5", "gold_label": "N" }
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/scitail/evaluator/answers.jsonl/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/scitail/evaluator/answers.jsonl",
"repo_id": "ContextualSP",
"token_count": 90
} | 254 |
import random
from random import shuffle
import os
from tqdm import tqdm
def expand_numbers_in_text(text, delim=" ", ignore_chars=[","], reverse_num=False):
number_pattern = r"[-+]?[.]?[\d]+(,\d+)*[\.]?\d*(?:[eE][-+]?\d+)?%?"
num_char_spans = [(m.start(0), m.end(0)) for m in re.finditer(number_pattern, text)]... | ContextualSP/poet/synthesize_math_corpus.py/0 | {
"file_path": "ContextualSP/poet/synthesize_math_corpus.py",
"repo_id": "ContextualSP",
"token_count": 1702
} | 255 |
#!/usr/bin/env bash
split=mcd1
data_path=../data/$split/
key=$split-sketch
model_path=../model/sketch_prediction-$key
output_file=train_log-$key
echo $output_file
mkdir $model_path
CUDA_VISIBLE_DEVICES=4 python3 main.py \
--src_path $data_path/train/train_encode.txt --trg_path $data_path/train/train_sketch.txt \
--s... | ContextualSP/poset_decoding/sketch_prediction/train.sh/0 | {
"file_path": "ContextualSP/poset_decoding/sketch_prediction/train.sh",
"repo_id": "ContextualSP",
"token_count": 281
} | 256 |
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=_build
set SPHINXPROJ=MatchZoo
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Ma... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/docs/make.bat/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/docs/make.bat",
"repo_id": "ContextualSP",
"token_count": 321
} | 257 |
"""Matchzoo DataPack, pair-wise tuple (feature) and context as input."""
import typing
import inspect
from pathlib import Path
import functools
import dill
from tqdm import tqdm
import numpy as np
import pandas as pd
import matchzoo
tqdm.pandas()
def _convert_to_list_index(
index: typing.Union[int, slice, np.... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/data_pack/data_pack.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/data_pack/data_pack.py",
"repo_id": "ContextualSP",
"token_count": 8291
} | 258 |
from .load_data import load_data
| ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/datasets/wiki_qa/__init__.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/datasets/wiki_qa/__init__.py",
"repo_id": "ContextualSP",
"token_count": 10
} | 259 |
from .precision import Precision
from .average_precision import AveragePrecision
from .discounted_cumulative_gain import DiscountedCumulativeGain
from .mean_reciprocal_rank import MeanReciprocalRank
from .mean_average_precision import MeanAveragePrecision
from .normalized_discounted_cumulative_gain import \
Normali... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/metrics/__init__.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/metrics/__init__.py",
"repo_id": "ContextualSP",
"token_count": 186
} | 260 |
"""An implementation of CDSSM (CLSM) model."""
import typing
import torch
from torch import nn
import torch.nn.functional as F
from matchzoo import preprocessors
from matchzoo.engine.base_model import BaseModel
from matchzoo.engine.param import Param
from matchzoo.engine.param_table import ParamTable
from matchzoo.en... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/cdssm.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/cdssm.py",
"repo_id": "ContextualSP",
"token_count": 3087
} | 261 |
"""matchzoo/models/README.md generater."""
from pathlib import Path
import tabulate
import inspect
import pandas as pd
import matchzoo
def _generate():
full = _make_title()
for model_class in matchzoo.models.list_available():
full += _make_model_class_subtitle(model_class)
full += _make_doc... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/parameter_readme_generator.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/parameter_readme_generator.py",
"repo_id": "ContextualSP",
"token_count": 815
} | 262 |
"""Bert Preprocessor."""
from pytorch_transformers import BertTokenizer
from . import units
from matchzoo import DataPack
from matchzoo.engine.base_preprocessor import BasePreprocessor
class BertPreprocessor(BasePreprocessor):
"""
Baisc preprocessor helper.
:param mode: String, supported mode can be re... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/bert_preprocessor.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/bert_preprocessor.py",
"repo_id": "ContextualSP",
"token_count": 528
} | 263 |
import nltk
from .unit import Unit
class StopRemoval(Unit):
"""
Process unit to remove stop words.
Example:
>>> unit = StopRemoval()
>>> unit.transform(['a', 'the', 'test'])
['test']
>>> type(unit.stopwords)
<class 'list'>
"""
def __init__(self, lang: str... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/units/stop_removal.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/units/stop_removal.py",
"repo_id": "ContextualSP",
"token_count": 478
} | 264 |
import inspect
def list_recursive_concrete_subclasses(base):
"""List all concrete subclasses of `base` recursively."""
return _filter_concrete(_bfs(base))
def _filter_concrete(classes):
return list(filter(lambda c: not inspect.isabstract(c), classes))
def _bfs(base):
return base.__subclasses__() +... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/utils/list_recursive_subclasses.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/utils/list_recursive_subclasses.py",
"repo_id": "ContextualSP",
"token_count": 152
} | 265 |
import pytest
from matchzoo.engine.param import Param
from matchzoo.engine.param_table import ParamTable
from matchzoo.engine.hyper_spaces import quniform
@pytest.fixture
def param_table():
params = ParamTable()
params.add(Param('ham', 'Parma Ham'))
return params
def test_get(param_table):
assert p... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/engine/test_param_table.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/engine/test_param_table.py",
"repo_id": "ContextualSP",
"token_count": 320
} | 266 |
<jupyter_start><jupyter_code>%run init.ipynb
preprocessor = mz.models.ArcI.get_default_preprocessor(
filter_mode='df',
filter_low_freq=2,
)
train_pack_processed = preprocessor.fit_transform(train_pack_raw)
dev_pack_processed = preprocessor.transform(dev_pack_raw)
test_pack_processed = preprocessor.transform(tes... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/arci.ipynb/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/arci.ipynb",
"repo_id": "ContextualSP",
"token_count": 939
} | 267 |
{
"aggregation_loss_weight": 1.0,
"aggregation_temperature": 1.0,
"allow_empty_column_selection": false,
"answer_loss_cutoff": null,
"answer_loss_importance": 1.0,
"architectures": [
"TapasModel"
],
"attention_probs_dropout_prob": 0.0,
"average_approximation_function": "ratio",... | ContextualSP/robustness_of_text_to_sql/CTA/tapas-torch/tapas_retrieval/tapas_nq_hn_retriever_large_table/config.json/0 | {
"file_path": "ContextualSP/robustness_of_text_to_sql/CTA/tapas-torch/tapas_retrieval/tapas_nq_hn_retriever_large_table/config.json",
"repo_id": "ContextualSP",
"token_count": 716
} | 268 |
set seed=1
set config_file=train_configs/concat.none.jsonnet
set model_file=checkpoints_cosql/cosql_concat_none_model
set tables_file=dataset_cosql/tables.json
set database_path=dataset_cosql/database
set dataset_path=dataset_cosql
set train_data_path=dataset_cosql/train.json
set validation_data_path=dataset_cosql/dev.... | ContextualSP/semantic_parsing_in_context/bash_files/windows/train_cosql.bat/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/bash_files/windows/train_cosql.bat",
"repo_id": "ContextualSP",
"token_count": 377
} | 269 |
import json
import shutil
import sys
from allennlp.commands import main
if __name__ == '__main__':
serialization_dir = "checkpoints/debug_model"
config_file = "train_configs_bert/concat.none.mem.jsonnet"
overrides = json.dumps({
"dataset_reader.tables_file": "dataset_sparc/tables.json",
"... | ContextualSP/semantic_parsing_in_context/debug.py/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/debug.py",
"repo_id": "ContextualSP",
"token_count": 529
} | 270 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from typing import Dict, List
import matplotlib
import torch
from allennlp.data.vocabulary import Vocabulary
from tensorboardX import SummaryWriter
matplotlib.use('agg', warn=False, force=True)
EMOJI_CORRECT = "😋"
EMOJI_ERROR ... | ContextualSP/semantic_parsing_in_context/models/visualizer.py/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/models/visualizer.py",
"repo_id": "ContextualSP",
"token_count": 1318
} | 271 |
from easydict import EasyDict as edict
import yaml
cfg = edict()
def _edict2dict(dest_dict, src_edict):
if isinstance(dest_dict, dict) and isinstance(src_edict, dict):
for k, v in src_edict.items():
if not isinstance(v, edict):
dest_dict[k] = v
else:
... | Cream/AutoFormer/lib/config.py/0 | {
"file_path": "Cream/AutoFormer/lib/config.py",
"repo_id": "Cream",
"token_count": 470
} | 272 |
import argparse
import datetime
import numpy as np
import time
import torch
import torch.backends.cudnn as cudnn
import json
import yaml
from pathlib import Path
from timm.data import Mixup
from timm.models import create_model
from timm.loss import LabelSmoothingCrossEntropy, SoftTargetCrossEntropy
from timm.scheduler ... | Cream/AutoFormer/supernet_train.py/0 | {
"file_path": "Cream/AutoFormer/supernet_train.py",
"repo_id": "Cream",
"token_count": 8777
} | 273 |
from .alexnet import AlexNet
from .vgg import VGG, make_vgg_layer
from .resnet import ResNet, make_res_layer
from .weight_init import (constant_init, xavier_init, normal_init,
uniform_init, kaiming_init, caffe2_xavier_init)
__all__ = [
'AlexNet', 'VGG', 'make_vgg_layer', 'ResNet', 'make_r... | Cream/CDARTS/CDARTS_detection/mmcv/cnn/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/cnn/__init__.py",
"repo_id": "Cream",
"token_count": 192
} | 274 |
import cv2
import numpy as np
def iminvert(img):
"""Invert (negate) an image
Args:
img (ndarray): Image to be inverted.
Returns:
ndarray: The inverted image.
"""
return np.full_like(img, 255) - img
def bgr2gray(img, keepdim=False):
"""Convert a BGR image to grayscale image.
... | Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/colorspace.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/colorspace.py",
"repo_id": "Cream",
"token_count": 768
} | 275 |
from ..utils import master_only
from .hook import Hook
class CheckpointHook(Hook):
def __init__(self,
interval=-1,
save_optimizer=True,
out_dir=None,
**kwargs):
self.interval = interval
self.save_optimizer = save_optimizer
... | Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/checkpoint.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/checkpoint.py",
"repo_id": "Cream",
"token_count": 343
} | 276 |
import logging
import os
import os.path as osp
import time
import math
import torch
import numpy as np
import mmcv
from . import hooks
from .checkpoint import load_checkpoint, save_checkpoint
from .hooks import (CheckpointHook, Hook, IterTimerHook, LrUpdaterHook,
OptimizerHook, OptimizerArchHook, l... | Cream/CDARTS/CDARTS_detection/mmcv/runner/runner.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/runner.py",
"repo_id": "Cream",
"token_count": 7773
} | 277 |
STUFF = "Hi"
import numpy as np
cimport numpy as np
np.import_array()
cdef extern from "flow_warp.hpp":
void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode)
def flow_warp_c(np.ndarray[double, ndim=3, mod... | Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.pyx/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.pyx",
"repo_id": "Cream",
"token_count": 412
} | 278 |
from __future__ import division
import re
from collections import OrderedDict
import torch
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import Runner, DistSamplerSeedHook, obj_from_dict
from mmdet import datasets
from mmdet.core import (DistEvalHook, DistOptimizerHook,
... | Cream/CDARTS/CDARTS_detection/mmdet/apis/train.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/apis/train.py",
"repo_id": "Cream",
"token_count": 4481
} | 279 |
from abc import ABCMeta, abstractmethod
import torch
from .sampling_result import SamplingResult
class BaseSampler(metaclass=ABCMeta):
def __init__(self,
num,
pos_fraction,
neg_pos_ub=-1,
add_gt_as_proposals=True,
**kwargs):
... | Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/base_sampler.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/base_sampler.py",
"repo_id": "Cream",
"token_count": 1360
} | 280 |
from .decorators import auto_fp16, force_fp32
from .hooks import Fp16OptimizerHook, wrap_fp16_model
__all__ = ['auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model']
| Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/__init__.py",
"repo_id": "Cream",
"token_count": 73
} | 281 |
import logging
import os.path as osp
import tempfile
import mmcv
import numpy as np
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
from mmdet.core import eval_recalls
from mmdet.utils import print_log
from .custom import CustomDataset
from .registry import DATASETS
@DATASETS.register_mo... | Cream/CDARTS/CDARTS_detection/mmdet/datasets/coco.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/datasets/coco.py",
"repo_id": "Cream",
"token_count": 8194
} | 282 |
import os.path as osp
import xml.etree.ElementTree as ET
import mmcv
from .registry import DATASETS
from .xml_style import XMLDataset
@DATASETS.register_module
class WIDERFaceDataset(XMLDataset):
"""
Reader for the WIDER Face dataset in PASCAL VOC format.
Conversion scripts can be found in
https://g... | Cream/CDARTS/CDARTS_detection/mmdet/datasets/wider_face.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/datasets/wider_face.py",
"repo_id": "Cream",
"token_count": 645
} | 283 |
""" PyTorch EfficientNet Family
An implementation of EfficienNet that covers variety of related models with efficient architectures:
* EfficientNet (B0-B8, L2 + Tensorflow pretrained AutoAug/RandAug/AdvProp/NoisyStudent weight ports)
- EfficientNet: Rethinking Model Scaling for CNNs - https://arxiv.org/abs/1905.119... | Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/efficientnet.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/efficientnet.py",
"repo_id": "Cream",
"token_count": 37124
} | 284 |
# --------------------------------------------------------
# Copyright (c) 2019 Jianyuan Guo (guojianyuan1@huawei.com)
# --------------------------------------------------------
# from .darts_head_search import DartsHead
from .mbblock_head_search import MbblockHead
def build_search_head(cfg):
"""Build head model... | Cream/CDARTS/CDARTS_detection/mmdet/models/bbox_heads/auto_head/build_head.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/bbox_heads/auto_head/build_head.py",
"repo_id": "Cream",
"token_count": 264
} | 285 |
from .two_stage import TwoStageDetector
from ..registry import DETECTORS
@DETECTORS.register_module
class MaskRCNN(TwoStageDetector):
def __init__(self,
backbone,
rpn_head,
bbox_roi_extractor,
bbox_head,
mask_roi_extractor,
... | Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/mask_rcnn.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/mask_rcnn.py",
"repo_id": "Cream",
"token_count": 549
} | 286 |
import functools
import torch.nn.functional as F
def reduce_loss(loss, reduction):
"""Reduce loss as specified.
Args:
loss (Tensor): Elementwise loss tensor.
reduction (str): Options are "none", "mean" and "sum".
Return:
Tensor: Reduced loss tensor.
"""
reduction_enum = ... | Cream/CDARTS/CDARTS_detection/mmdet/models/losses/utils.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/losses/utils.py",
"repo_id": "Cream",
"token_count": 1172
} | 287 |
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import xavier_init
from mmcv.cnn import caffe2_xavier_init
from mmdet.core import auto_fp16
from ..registry import NECKS
from ..utils import ConvModule
norm_cfg_ = {
'BN': nn.BatchNorm2d,
'SyncBN': nn.SyncBatchNorm,
'GN': nn.... | Cream/CDARTS/CDARTS_detection/mmdet/models/necks/nas_fpn.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/necks/nas_fpn.py",
"repo_id": "Cream",
"token_count": 3831
} | 288 |
import numpy as np
import torch.nn as nn
def xavier_init(module, gain=1, bias=0, distribution='normal'):
assert distribution in ['uniform', 'normal']
if distribution == 'uniform':
nn.init.xavier_uniform_(module.weight, gain=gain)
else:
nn.init.xavier_normal_(module.weight, gain=gain)
i... | Cream/CDARTS/CDARTS_detection/mmdet/models/utils/weight_init.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/utils/weight_init.py",
"repo_id": "Cream",
"token_count": 652
} | 289 |
from .functions.masked_conv import masked_conv2d
from .modules.masked_conv import MaskedConv2d
__all__ = ['masked_conv2d', 'MaskedConv2d']
| Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/__init__.py",
"repo_id": "Cream",
"token_count": 54
} | 290 |
from .roi_align import RoIAlign, roi_align
__all__ = ['roi_align', 'RoIAlign']
| Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/__init__.py",
"repo_id": "Cream",
"token_count": 35
} | 291 |
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='roi_pool',
ext_modules=[
CUDAExtension('roi_pool_cuda', [
'src/roi_pool_cuda.cpp',
'src/roi_pool_kernel.cu',
])
],
cmdclass={'build_ext': BuildExtension}... | Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/setup.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/setup.py",
"repo_id": "Cream",
"token_count": 150
} | 292 |
import contextlib
import sys
import time
import torch
if sys.version_info >= (3, 7):
@contextlib.contextmanager
def profile_time(trace_name,
name,
enabled=True,
stream=None,
end_stream=None):
"""Print time spent by CP... | Cream/CDARTS/CDARTS_detection/mmdet/utils/profiling.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/utils/profiling.py",
"repo_id": "Cream",
"token_count": 685
} | 293 |
# ------------------------------------------------------------------------------
# Loads Cityscapes semantic dataset.
# Written by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
import glob
import os
import numpy as np
from .base_dataset import Bas... | Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes.py",
"repo_id": "Cream",
"token_count": 2451
} | 294 |
# ------------------------------------------------------------------------------
# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/panoptic_evaluation.py
# Modified by Bowen Cheng (bcheng9@illinois.edu)
# -----------------------------------------------------------------------... | Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/panoptic.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/panoptic.py",
"repo_id": "Cream",
"token_count": 2162
} | 295 |
from torch import nn
from .criterion import RegularCE, OhemCE, DeepLabCE
L1Loss = nn.L1Loss
MSELoss = nn.MSELoss
CrossEntropyLoss = nn.CrossEntropyLoss
| Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/__init__.py",
"repo_id": "Cream",
"token_count": 63
} | 296 |
# ------------------------------------------------------------------------------
# This file contains primitives for multi-gpu communication.
# This is useful when doing distributed training.
# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/comm.py
# Modified by Bowen Cheng (bche... | Cream/CDARTS/CDARTS_segmentation/segmentation/utils/comm.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/utils/comm.py",
"repo_id": "Cream",
"token_count": 3158
} | 297 |
import numpy as np
from datasets.BaseDataset import BaseDataset
class Cityscapes(BaseDataset):
trans_labels = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 31, 32, 33]
@classmethod
def get_class_colors(*args):
return [[128, 64, 128], [244, 35, 232], [70, 70, ... | Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes.py",
"repo_id": "Cream",
"token_count": 823
} | 298 |
""" Common distribution utilities
Hacked by Hongyuan Yu
"""
from copy import deepcopy
import torch
from torch import distributed as dist
import logging
from collections import OrderedDict
_logger = logging.getLogger(__name__)
def reduce_tensor(tensor, n):
rt = tensor.clone()
dist.all_reduce(rt, op=dist.Re... | Cream/CDARTS/CDARTS_segmentation/tools/utils/dist_utils.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/tools/utils/dist_utils.py",
"repo_id": "Cream",
"token_count": 1391
} | 299 |
# encoding: utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os.path as osp
import sys
import numpy as np
from easydict import EasyDict as edict
C = edict()
config = C
cfg = C
C.seed = 12345
"""please config ROOT_dir and user when u first usi... | Cream/CDARTS/CDARTS_segmentation/train/config_train.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/train/config_train.py",
"repo_id": "Cream",
"token_count": 1549
} | 300 |
import numpy as np
import torch
class Seg_Metrics(object):
def __init__(self, n_classes=19):
self.n_classes = n_classes
self.total_inter = np.zeros(n_classes)
self.total_union = np.zeros(n_classes)
def update(self, inter, union, N):
self.total_inter += inter * N
self.t... | Cream/CDARTS/CDARTS_segmentation/train/seg_metrics.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/train/seg_metrics.py",
"repo_id": "Cream",
"token_count": 1478
} | 301 |
import torch
import numpy as np
import torchvision.datasets as dset
import torchvision.transforms as transforms
from datasets.data_utils import SubsetDistributedSampler
from datasets.data_utils import CIFAR10Policy, Cutout
def data_transforms_cifar(config, cutout=False):
CIFAR_MEAN = [0.49139968, 0.48215827, 0.44... | Cream/CDARTS/benchmark201/datasets/cifar.py/0 | {
"file_path": "Cream/CDARTS/benchmark201/datasets/cifar.py",
"repo_id": "Cream",
"token_count": 1462
} | 302 |
""" Genotypes
- Genotype: normal/reduce gene + normal/reduce cell output connection (concat)
- gene: discrete ops information (w/o output connection)
- dag: real ops (can be mixed or discrete, but Genotype has only discrete information itself)
"""
from collections import namedtuple
import torch
import torch... | Cream/CDARTS/benchmark201/utils/genotypes.py/0 | {
"file_path": "Cream/CDARTS/benchmark201/utils/genotypes.py",
"repo_id": "Cream",
"token_count": 5956
} | 303 |
import torch
import torch.nn as nn
import torch.nn.functional as F
import lib.utils.genotypes as gt
import logging
import copy
from lib.models import ops
from lib.models.search_cells import SearchCell
from lib.models.augment_cells import AugmentCell
from lib.models.aux_head import AuxiliaryHeadCIFAR, AuxiliaryHeadImag... | Cream/CDARTS/lib/models/cdarts_controller.py/0 | {
"file_path": "Cream/CDARTS/lib/models/cdarts_controller.py",
"repo_id": "Cream",
"token_count": 16960
} | 304 |
# 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 __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_litera... | Cream/Cream/lib/config.py/0 | {
"file_path": "Cream/Cream/lib/config.py",
"repo_id": "Cream",
"token_count": 1555
} | 305 |
# 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
def search_for_layer(flops_op_dict, arch_def, flops_minimum, flops_maximum):
sta_num = [1, 1, 1, 1, 1]
order = [2, 3, 4, 1, 0, 2, 3, 4, 1,... | Cream/Cream/lib/utils/search_structure_supernet.py/0 | {
"file_path": "Cream/Cream/lib/utils/search_structure_supernet.py",
"repo_id": "Cream",
"token_count": 910
} | 306 |
dataset_type = 'CocoDataset'
data_root = 'data/coco/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True... | Cream/EfficientViT/downstream/configs/_base_/datasets/coco_detection.py/0 | {
"file_path": "Cream/EfficientViT/downstream/configs/_base_/datasets/coco_detection.py",
"repo_id": "Cream",
"token_count": 795
} | 307 |
#!/usr/bin/env bash
CONFIG=$1
CHECKPOINT=$2
GPUS=$3
PORT=${PORT:-29500}
PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \
python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \
$(dirname "$0")/test.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4}
| Cream/EfficientViT/downstream/dist_test.sh/0 | {
"file_path": "Cream/EfficientViT/downstream/dist_test.sh",
"repo_id": "Cream",
"token_count": 118
} | 308 |
import torch
import torch.distributed as dist
import math
class RASampler(torch.utils.data.Sampler):
"""Sampler that restricts data loading to a subset of the dataset for distributed,
with repeated augmentation.
It ensures that different each augmented version of a sample will be visible to a
differen... | Cream/MiniViT/Mini-DeiT/samplers.py/0 | {
"file_path": "Cream/MiniViT/Mini-DeiT/samplers.py",
"repo_id": "Cream",
"token_count": 911
} | 309 |
import os
import torch
import numpy as np
import torch.distributed as dist
from torchvision import datasets, transforms
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.data import Mixup
from timm.data import create_transform
from timm.data.transforms import _pil_interp
try:
fro... | Cream/MiniViT/Mini-Swin/data/build.py/0 | {
"file_path": "Cream/MiniViT/Mini-Swin/data/build.py",
"repo_id": "Cream",
"token_count": 2386
} | 310 |
# Adapted from https://github.com/princeton-nlp/CoFiPruning/blob/main/models/l0_module.py
# MIT license
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class L0Module(nn.Module):
limit_a, limit_b, epsilon = -.1, 1.1, 1e-6
all_types = ["hidden_z", "heads_z", "... | Cream/TinyCLIP/src/open_clip/l0module.py/0 | {
"file_path": "Cream/TinyCLIP/src/open_clip/l0module.py",
"repo_id": "Cream",
"token_count": 7704
} | 311 |
""" CLIP tokenizer
Copied from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI.
"""
import gzip
import html
import os
from functools import lru_cache
from typing import Union, List
import ftfy
import regex as re
import torch
@lru_cache()
def default_bpe():
return os.path.join(o... | Cream/TinyCLIP/src/open_clip/tokenizer.py/0 | {
"file_path": "Cream/TinyCLIP/src/open_clip/tokenizer.py",
"repo_id": "Cream",
"token_count": 3499
} | 312 |
import torch
from contextlib import suppress
# amp_bfloat16 is more stable than amp float16 for clip training
def get_autocast(precision):
if precision == 'amp':
return torch.cuda.amp.autocast
elif precision == 'amp_bfloat16':
return lambda: torch.cuda.amp.autocast(dtype=torch.bfloat16)
e... | Cream/TinyCLIP/src/training/precision.py/0 | {
"file_path": "Cream/TinyCLIP/src/training/precision.py",
"repo_id": "Cream",
"token_count": 169
} | 313 |
""" Quick n Simple Image Folder, Tarfile based DataSet
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch.utils.data as data
import os
import torch
import logging
from PIL import Image
from .parsers import create_parser
_logger = logging.getLogger(__name__)
_ERROR_RETRY = 50
class ImageDataset(d... | Cream/TinyViT/data/augmentation/dataset.py/0 | {
"file_path": "Cream/TinyViT/data/augmentation/dataset.py",
"repo_id": "Cream",
"token_count": 2122
} | 314 |
""" Random Erasing (Cutout)
Originally inspired by impl at https://github.com/zhunzhong07/Random-Erasing, Apache 2.0
Copyright Zhun Zhong & Liang Zheng
Hacked together by / Copyright 2020 Ross Wightman
"""
from .aug_random import random, np_random
import numpy as np
import math
import torch
def _get_pixels(per_pixe... | Cream/TinyViT/data/augmentation/random_erasing.py/0 | {
"file_path": "Cream/TinyViT/data/augmentation/random_erasing.py",
"repo_id": "Cream",
"token_count": 2458
} | 315 |
# --------------------------------------------------------
# TinyViT Learning rate scheduler
# Copyright (c) 2022 Microsoft
# Based on the code: Swin Transformer
# (https://github.com/microsoft/swin-transformer)
# --------------------------------------------------------
import torch
from timm.scheduler.cosine_lr imp... | Cream/TinyViT/lr_scheduler.py/0 | {
"file_path": "Cream/TinyViT/lr_scheduler.py",
"repo_id": "Cream",
"token_count": 2032
} | 316 |
Hiring research interns for neural architecture search projects: houwen.peng@microsoft.com
# Rethinking and Improving Relative Position Encoding for Vision Transformer
[[Paper]](https://openaccess.thecvf.com/content/ICCV2021/html/Wu_Rethinking_and_Improving_Relative_Position_Encoding_for_Vision_Transformer_ICCV_2021_... | Cream/iRPE/DETR-with-iRPE/README.md/0 | {
"file_path": "Cream/iRPE/DETR-with-iRPE/README.md",
"repo_id": "Cream",
"token_count": 3004
} | 317 |
# Modify from https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/activation.py
import warnings
from typing import Optional, Tuple
import torch
from torch import Tensor
from torch import nn
from torch.nn.init import xavier_uniform_
from torch.nn.init import constant_
from torch.nn.init import xavier_norma... | Cream/iRPE/DETR-with-iRPE/models/rpe_attention/multi_head_attention.py/0 | {
"file_path": "Cream/iRPE/DETR-with-iRPE/models/rpe_attention/multi_head_attention.py",
"repo_id": "Cream",
"token_count": 4135
} | 318 |
""" Vision Transformer (ViT) in PyTorch
A PyTorch implement of Vision Transformers as described in
'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale' - https://arxiv.org/abs/2010.11929
The official jax code is released and available at https://github.com/google-research/vision_transformer
... | Cream/iRPE/DeiT-with-iRPE/rpe_vision_transformer.py/0 | {
"file_path": "Cream/iRPE/DeiT-with-iRPE/rpe_vision_transformer.py",
"repo_id": "Cream",
"token_count": 3582
} | 319 |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import logging
import time
import torch
from timm.data import Mixup
from torch.cuda.amp import autocast
from core.evaluate import accuracy
from utils.comm import comm
def train_one_epoch(config, train_loade... | CvT/lib/core/function.py/0 | {
"file_path": "CvT/lib/core/function.py",
"repo_id": "CvT",
"token_count": 3597
} | 320 |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch
from timm.scheduler import create_scheduler
def build_lr_scheduler(cfg, optimizer, begin_epoch):
if 'METHOD' not in cfg.TRAIN.LR_SCHEDULER:
raise ValueError('Please set TRAIN.LR_SCHED... | CvT/lib/scheduler/build.py/0 | {
"file_path": "CvT/lib/scheduler/build.py",
"repo_id": "CvT",
"token_count": 789
} | 321 |
"""
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft Corporation ("Microsoft") grants you a nonexclusive, perpetual,
royalty-free right to use, copy, and modify the software code provided by us
("Software Code"). You may not sublicense the Software Code or any use of it
(except to your affiliates... | anomalydetector/srcnn/generate_data.py/0 | {
"file_path": "anomalydetector/srcnn/generate_data.py",
"repo_id": "anomalydetector",
"token_count": 2168
} | 322 |
{
"version": "0.2.0",
"configurations": [
{
"name": "All-Toy-NoPareto",
"type": "python",
"request": "launch",
"program": "${cwd}/scripts/supergraph/main.py",
"console": "integratedTerminal"
},
{
"name": "All-Toy-Par... | archai/.vscode/launch.json/0 | {
"file_path": "archai/.vscode/launch.json",
"repo_id": "archai",
"token_count": 5507
} | 323 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import contextlib
import os
import psutil
import ray
import torch
import torch.distributed as dist
from torch import Tensor, nn
from torch.backends import cudnn
from torch.cuda.amp import GradScaler
from torch.nn import SyncBatchNorm
from torch.... | archai/archai/common/apex_utils.py/0 | {
"file_path": "archai/archai/common/apex_utils.py",
"repo_id": "archai",
"token_count": 5466
} | 324 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# adapted from https://github.com/ildoonet/pystopwatch2/blob/master/pystopwatch2/watch.py
import threading
import time
from collections import defaultdict
from enum import Enum
class _ClockState(Enum):
PAUSE = 0
RUN = 1
class _Clock:
... | archai/archai/common/stopwatch.py/0 | {
"file_path": "archai/archai/common/stopwatch.py",
"repo_id": "archai",
"token_count": 1019
} | 325 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Callable, Optional
from overrides import overrides
from torch.utils.data import Dataset
from torchvision.datasets import ImageNet
from torchvision.transforms import ToTensor
from archai.api.dataset_provider import DatasetProv... | archai/archai/datasets/cv/imagenet_dataset_provider.py/0 | {
"file_path": "archai/archai/datasets/cv/imagenet_dataset_provider.py",
"repo_id": "archai",
"token_count": 848
} | 326 |
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0.
# https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/LanguageModeling/Transformer-XL/pytorch/data_utils.py
from typing import Generator, Iterator, List, Optional, Tuple
import numpy as np
import torch
fro... | archai/archai/datasets/nlp/nvidia_data_loader_utils.py/0 | {
"file_path": "archai/archai/datasets/nlp/nvidia_data_loader_utils.py",
"repo_id": "archai",
"token_count": 5218
} | 327 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import random
from pathlib import Path
from typing import Optional
from overrides import overrides
from archai.api.dataset_provider import DatasetProvider
from archai.common.ordered_dict_logger import OrderedDictLogger
from archai.discrete_sear... | archai/archai/discrete_search/algos/successive_halving.py/0 | {
"file_path": "archai/archai/discrete_search/algos/successive_halving.py",
"repo_id": "archai",
"token_count": 1997
} | 328 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import pathlib
import shutil
from typing import Any, Dict, Optional
import torch
from overrides import overrides
from archai.discrete_search.api.archai_model import ArchaiModel
from archai.discrete_search.api.model_evaluator import ... | archai/archai/discrete_search/evaluators/nlp/transformer_flex_memory.py/0 | {
"file_path": "archai/archai/discrete_search/evaluators/nlp/transformer_flex_memory.py",
"repo_id": "archai",
"token_count": 1378
} | 329 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import json
from collections import OrderedDict
from copy import deepcopy
from pathlib import Path
from typing import Any, Dict, Optional, Union
import yaml
def build_arch_config(config_dict: Dict[str, Any]) -... | archai/archai/discrete_search/search_spaces/config/arch_config.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/config/arch_config.py",
"repo_id": "archai",
"token_count": 3014
} | 330 |
# coding=utf-8
# Copyright 2022 Salesforce authors, The EleutherAI, and HuggingFace Teams. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/l... | archai/archai/discrete_search/search_spaces/nlp/tfpp/backbones/codegen/model.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/nlp/tfpp/backbones/codegen/model.py",
"repo_id": "archai",
"token_count": 6869
} | 331 |
from torch import nn
from archai.discrete_search.search_spaces.config import ArchConfig
class SeparableConv1d(nn.Module):
def __init__(self, arch_config: ArchConfig, hidden_size: int,
total_heads: int, op_heads: int, **kwargs):
super().__init__()
self.hidden_size = hidden_size
... | archai/archai/discrete_search/search_spaces/nlp/tfpp/ops/sep_conv1d.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/nlp/tfpp/ops/sep_conv1d.py",
"repo_id": "archai",
"token_count": 520
} | 332 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn.functional as F
from overrides import overrides
from torch import nn
from archai.common.common import get_conf
from archai.supergraph.algos.gumbelsoftmax.gs_op import GsOp
from archai.supergraph.nas.finalizers import... | archai/archai/supergraph/algos/gumbelsoftmax/gs_finalizers.py/0 | {
"file_path": "archai/archai/supergraph/algos/gumbelsoftmax/gs_finalizers.py",
"repo_id": "archai",
"token_count": 1140
} | 333 |
# Copyright 2019 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agree... | archai/archai/supergraph/algos/nasbench101/model_metrics_pb2.py/0 | {
"file_path": "archai/archai/supergraph/algos/nasbench101/model_metrics_pb2.py",
"repo_id": "archai",
"token_count": 2728
} | 334 |
import os
from collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
__all__ = ['Inception3', 'inception_v3']
_InceptionOuputs = namedtuple('InceptionOuputs', ['logits', 'aux_logits'])
def inception_v3(pretrained=False, progress=True, device='cpu', **kwargs):
r"""Inc... | archai/archai/supergraph/models/inception.py/0 | {
"file_path": "archai/archai/supergraph/models/inception.py",
"repo_id": "archai",
"token_count": 6820
} | 335 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from typing import Callable, Optional, Type
import torch
from overrides import EnforceOverrides, overrides
from torch import Tensor
from archai.common import utils
from archai.common.config import Config
from archai.supergraph.dataset... | archai/archai/supergraph/nas/arch_trainer.py/0 | {
"file_path": "archai/archai/supergraph/nas/arch_trainer.py",
"repo_id": "archai",
"token_count": 1344
} | 336 |
import copy
import json
import os
import time
from collections import OrderedDict
from typing import Optional
import gorilla
import numpy as np
import ray
import torch
from hyperopt import hp
from ray.tune import register_trainable, run_experiments
from ray.tune.suggest import HyperOptSearch
from ray.tune.trial import... | archai/archai/supergraph/utils/augmented_searcher.py/0 | {
"file_path": "archai/archai/supergraph/utils/augmented_searcher.py",
"repo_id": "archai",
"token_count": 7179
} | 337 |
__include__: 'darts.yaml' # just use darts defaults
nas:
eval:
model_factory_spec: 'resnet18'
#darts loader/trainer
loader:
train_batch: 128 #96
cutout: 0
trainer:
aux_weight: 0.0
grad_clip: 0.0
drop_path_prob: 0.0 # probability that given edge will be dropped
ep... | archai/confs/algos/manual.yaml/0 | {
"file_path": "archai/confs/algos/manual.yaml",
"repo_id": "archai",
"token_count": 899
} | 338 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.