text stringlengths 5 22M | id stringlengths 12 177 | metadata dict | __index_level_0__ int64 0 1.37k |
|---|---|---|---|
import pytest
import matchzoo as mz
@pytest.mark.cron
def test_load_data():
train_data = mz.datasets.wiki_qa.load_data('train', task='ranking')
assert len(train_data) == 20360
train_data, _ = mz.datasets.wiki_qa.load_data('train',
task='classification',
... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/test_datasets.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/test_datasets.py",
"repo_id": "ContextualSP",
"token_count": 1742
} | 261 |
<jupyter_start><jupyter_code>%run init.ipynb
ranking_task = mz.tasks.Ranking(losses=mz.losses.RankCrossEntropyLoss(num_neg=10))
ranking_task.metrics = [
mz.metrics.NormalizedDiscountedCumulativeGain(k=3),
mz.metrics.NormalizedDiscountedCumulativeGain(k=5),
mz.metrics.MeanAveragePrecision()
]
preprocessor = ... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/drmm.ipynb/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/drmm.ipynb",
"repo_id": "ContextualSP",
"token_count": 937
} | 262 |
# MIT License
#
# Copyright (c) 2019 seq2struct contributors and Microsoft Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the ... | ContextualSP/unified_parser_text_to_sql/semparse/sql/spider.py/0 | {
"file_path": "ContextualSP/unified_parser_text_to_sql/semparse/sql/spider.py",
"repo_id": "ContextualSP",
"token_count": 2113
} | 263 |
import json
class Schema:
"""
Simple schema which maps table&column to a unique identifier
"""
def __init__(self, schema, table):
self._schema = schema
self._table = table
self._idMap = self._map(self._schema, self._table)
@property
def schema(self):
return se... | ContextualSP/unified_parser_text_to_sql/third_party/spider/preprocess/schema.py/0 | {
"file_path": "ContextualSP/unified_parser_text_to_sql/third_party/spider/preprocess/schema.py",
"repo_id": "ContextualSP",
"token_count": 1080
} | 264 |
MLP_RATIO: [[4.0, 4.0], [4.0, 4.0], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0,4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0], [4.0, 4.0]]
NUM_HEADS: [[3,3], [6,6], [12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12], [24,24]]
EMBED_DIM: [96,192,384,768]
DEPTHS: [ 2, 2, 18, 2 ]
WINDOW_SIZE: [[14,14], [14,14], [14,1... | Cream/AutoFormerV2/configs/S3-S.yaml/0 | {
"file_path": "Cream/AutoFormerV2/configs/S3-S.yaml",
"repo_id": "Cream",
"token_count": 254
} | 265 |
from .io import load, dump, register_handler
from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler
from .parse import list_from_file, dict_from_file
__all__ = [
'load', 'dump', 'register_handler', 'BaseFileHandler', 'JsonHandler',
'PickleHandler', 'YamlHandler', 'list_from_file', 'dict... | Cream/CDARTS/CDARTS_detection/mmcv/fileio/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/fileio/__init__.py",
"repo_id": "Cream",
"token_count": 111
} | 266 |
from .collate import collate
from .data_container import DataContainer
from .data_parallel import MMDataParallel
from .distributed import MMDistributedDataParallel
from .scatter_gather import scatter, scatter_kwargs
__all__ = [
'collate', 'DataContainer', 'MMDataParallel', 'MMDistributedDataParallel',
'scatter... | Cream/CDARTS/CDARTS_detection/mmcv/parallel/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/parallel/__init__.py",
"repo_id": "Cream",
"token_count": 107
} | 267 |
from abc import ABCMeta, abstractmethod
from ..hook import Hook
class LoggerHook(Hook):
"""Base class for logger hooks.
Args:
interval (int): Logging interval (every k iterations).
ignore_last (bool): Ignore the log of last iterations in each epoch
if less than `interval`.
... | Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/base.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/base.py",
"repo_id": "Cream",
"token_count": 1003
} | 268 |
import os
import os.path as osp
import sys
from pathlib import Path
import six
from .misc import is_str
if sys.version_info <= (3, 3):
FileNotFoundError = IOError
else:
FileNotFoundError = FileNotFoundError
def is_filepath(x):
if is_str(x) or isinstance(x, Path):
return True
else:
r... | Cream/CDARTS/CDARTS_detection/mmcv/utils/path.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/utils/path.py",
"repo_id": "Cream",
"token_count": 895
} | 269 |
from __future__ import division
import numpy as np
from mmcv.image import rgb2bgr
from mmcv.video import flowread
from .image import imshow
def flowshow(flow, win_name='', wait_time=0):
"""Show optical flow.
Args:
flow (ndarray or str): The optical flow to be displayed.
win_name (str): The ... | Cream/CDARTS/CDARTS_detection/mmcv/visualization/optflow.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmcv/visualization/optflow.py",
"repo_id": "Cream",
"token_count": 1533
} | 270 |
import torch
from ..bbox import build_assigner, build_sampler, PseudoSampler
from ..utils import unmap, multi_apply
def calc_region(bbox, ratio, featmap_size=None):
"""Calculate a proportional bbox region.
The bbox center are fixed and the new h' and w' is h * ratio and w * ratio.
Args:
bbox (T... | Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/guided_anchor_target.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/guided_anchor_target.py",
"repo_id": "Cream",
"token_count": 6207
} | 271 |
import torch
from .base_sampler import BaseSampler
from .sampling_result import SamplingResult
class PseudoSampler(BaseSampler):
def __init__(self, **kwargs):
pass
def _sample_pos(self, **kwargs):
raise NotImplementedError
def _sample_neg(self, **kwargs):
raise NotImplementedEr... | Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/pseudo_sampler.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/pseudo_sampler.py",
"repo_id": "Cream",
"token_count": 380
} | 272 |
import torch
import numpy as np
import mmcv
def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list,
cfg):
cfg_list = [cfg for _ in range(len(pos_proposals_list))]
mask_targets = map(mask_target_single, pos_proposals_list,
pos_assigned_gt_inds_list, ... | Cream/CDARTS/CDARTS_detection/mmdet/core/mask/mask_target.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/mask/mask_target.py",
"repo_id": "Cream",
"token_count": 745
} | 273 |
from __future__ import division
import math
import numpy as np
import torch
from mmcv.runner.utils import get_dist_info
from torch.utils.data import DistributedSampler as _DistributedSampler
from torch.utils.data import Sampler
class DistributedSampler(_DistributedSampler):
def __init__(self, dataset, num_repli... | Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/sampler.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/sampler.py",
"repo_id": "Cream",
"token_count": 3882
} | 274 |
import torch
import torch.nn as nn
from mmcv.cnn import normal_init
from mmdet.core import multi_apply, multiclass_nms, distance2bbox, force_fp32
from ..builder import build_loss
from ..registry import HEADS
from ..utils import bias_init_with_prob, Scale, ConvModule
INF = 1e8
@HEADS.register_module
class FCOSHead(n... | Cream/CDARTS/CDARTS_detection/mmdet/models/anchor_heads/fcos_head.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/anchor_heads/fcos_head.py",
"repo_id": "Cream",
"token_count": 8639
} | 275 |
from collections import defaultdict, OrderedDict
from functools import partial
class FeatureHooks:
def __init__(self, hooks, named_modules):
# setup feature hooks
modules = {k: v for k, v in named_modules}
for h in hooks:
hook_name = h['name']
m = modules[hook_name... | Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/feature_hooks.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/backbones/feature_hooks.py",
"repo_id": "Cream",
"token_count": 522
} | 276 |
import torch.nn as nn
from mmcv.cnn.weight_init import normal_init, xavier_init
from ..backbones.resnet import Bottleneck
from ..registry import HEADS
from ..utils import ConvModule
from .bbox_head import BBoxHead
class BasicResBlock(nn.Module):
"""Basic residual block.
This block is a little different from ... | Cream/CDARTS/CDARTS_detection/mmdet/models/bbox_heads/double_bbox_head.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/bbox_heads/double_bbox_head.py",
"repo_id": "Cream",
"token_count": 2805
} | 277 |
from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_proposals,
merge_aug_bboxes, merge_aug_masks, multiclass_nms)
class RPNTestMixin(object):
def simple_test_rpn(self, x, img_meta, rpn_test_cfg):
rpn_outs = self.rpn_head(x)
proposal_inputs = rpn_outs + (img_meta, rpn... | Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/test_mixins.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/test_mixins.py",
"repo_id": "Cream",
"token_count": 3836
} | 278 |
from .fcn_mask_head import FCNMaskHead
from ..registry import HEADS
from ..utils import ConvModule
@HEADS.register_module
class HTCMaskHead(FCNMaskHead):
def __init__(self, *args, **kwargs):
super(HTCMaskHead, self).__init__(*args, **kwargs)
self.conv_res = ConvModule(
self.conv_out_c... | Cream/CDARTS/CDARTS_detection/mmdet/models/mask_heads/htc_mask_head.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/mask_heads/htc_mask_head.py",
"repo_id": "Cream",
"token_count": 595
} | 279 |
from mmdet.utils import Registry
BACKBONES = Registry('backbone')
NECKS = Registry('neck')
ROI_EXTRACTORS = Registry('roi_extractor')
SHARED_HEADS = Registry('shared_head')
HEADS = Registry('head')
LOSSES = Registry('loss')
DETECTORS = Registry('detector') | Cream/CDARTS/CDARTS_detection/mmdet/models/registry.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/registry.py",
"repo_id": "Cream",
"token_count": 86
} | 280 |
import torch
from torch.autograd import Function
from .. import deform_pool_cuda
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(ctx,
data,
rois,
offset,
spatial_scale,
out_size,
out_channels,... | Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_pool.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_pool.py",
"repo_id": "Cream",
"token_count": 1195
} | 281 |
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='masked_conv2d_cuda',
ext_modules=[
CUDAExtension('masked_conv2d_cuda', [
'src/masked_conv2d_cuda.cpp',
'src/masked_conv2d_kernel.cu',
]),
],
cmdclass={'b... | Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/setup.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/setup.py",
"repo_id": "Cream",
"token_count": 162
} | 282 |
from torch.nn.modules.module import Module
from ..functions.roi_align import RoIAlignFunction
class RoIAlign(Module):
def __init__(self, out_size, spatial_scale, sample_num=0):
super(RoIAlign, self).__init__()
self.out_size = out_size
self.spatial_scale = float(spatial_scale)
sel... | Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/roi_align.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/roi_align.py",
"repo_id": "Cream",
"token_count": 235
} | 283 |
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from .. import sigmoid_focal_loss_cuda
class SigmoidFocalLossFunction(Function):
@staticmethod
def forward(ctx, input, target, gamma=2.0, alpha=0.25):
ctx.save_for_backward(input, target)
num_classes ... | Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py",
"repo_id": "Cream",
"token_count": 516
} | 284 |
import os
import argparse
import os.path as osp
import torch
import torch.distributed as dist
import shutil
import tempfile
import mmcv
from mmcv.runner import load_checkpoint, get_dist_info
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmdet.apis import init_dist
from mmdet.core import res... | Cream/CDARTS/CDARTS_detection/test.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_detection/test.py",
"repo_id": "Cream",
"token_count": 3205
} | 285 |
import math
import torch
import random
import numpy as np
import torch.nn as nn
from numpy import int64 as int64
import torchvision.transforms as transforms
from PIL import Image, ImageOps, ImageFilter
class Normalize(object):
"""Normalize a tensor image with mean and standard deviation.
Args:
mean (... | Cream/CDARTS/CDARTS_segmentation/dataloaders/custom_transforms.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/dataloaders/custom_transforms.py",
"repo_id": "Cream",
"token_count": 5277
} | 286 |
# ------------------------------------------------------------------------------
# Builds transformation for both image and labels.
# Written by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
from . import transforms as T
def build_transforms(datas... | Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/build.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/build.py",
"repo_id": "Cream",
"token_count": 789
} | 287 |
from .distributed_sampler import TrainingSampler, InferenceSampler
| Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/__init__.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/__init__.py",
"repo_id": "Cream",
"token_count": 17
} | 288 |
# ------------------------------------------------------------------------------
# Reference: https://github.com/pytorch/vision/blob/master/torchvision/models/mnasnet.py
# Modified by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
import math
import ... | Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mnasnet.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mnasnet.py",
"repo_id": "Cream",
"token_count": 5326
} | 289 |
# ------------------------------------------------------------------------------
# DeepLabV3+ meta architecture.
# Written by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
from collections import OrderedDict
import torch
from torch import nn
from ... | Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3plus.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3plus.py",
"repo_id": "Cream",
"token_count": 1035
} | 290 |
# ------------------------------------------------------------------------------
# Saves output to png image for visualization.
# Reference: https://github.com/tensorflow/models/blob/master/research/deeplab/utils/save_annotation.py
# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils... | Cream/CDARTS/CDARTS_segmentation/segmentation/utils/save_annotation.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/utils/save_annotation.py",
"repo_id": "Cream",
"token_count": 6684
} | 291 |
import numpy as np
class Evaluator(object):
def __init__(self, num_class):
self.num_class = num_class
self.confusion_matrix = np.zeros((self.num_class,)*2)
def Pixel_Accuracy(self):
Acc = np.diag(self.confusion_matrix).sum() / self.confusion_matrix.sum()
return Acc
def Pi... | Cream/CDARTS/CDARTS_segmentation/tools/utils/metrics.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/tools/utils/metrics.py",
"repo_id": "Cream",
"token_count": 865
} | 292 |
_BASE_: Base-PanopticDeepLab-OS16.yaml
MODEL:
WEIGHTS: "detectron2://DeepLab/R-52.pkl"
PIXEL_MEAN: [123.675, 116.280, 103.530]
PIXEL_STD: [58.395, 57.120, 57.375]
BACKBONE:
NAME: "build_resnet_deeplab_backbone"
RESNETS:
DEPTH: 50
NORM: "SyncBN"
RES5_MULTI_GRID: [1, 2, 4]
STEM_TYPE: "deepla... | Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml",
"repo_id": "Cream",
"token_count": 244
} | 293 |
from __future__ import division
import os
import sys
import time
import glob
import json
import logging
import argparse
from tqdm import tqdm
import torch
import torch.nn as nn
import torch.utils
import torch.nn.functional as F
import torch.optim as optim
import torch.distributed as dist
from tensorboardX import Summa... | Cream/CDARTS/CDARTS_segmentation/train/train_ade20k_cydas.py/0 | {
"file_path": "Cream/CDARTS/CDARTS_segmentation/train/train_ade20k_cydas.py",
"repo_id": "Cream",
"token_count": 10511
} | 294 |
import torch
import torch.nn as nn
import torch.nn.functional as F
import logging
import copy
from models.search_cells import SearchCell
from models.augment_cells import InferCell
from models.aux_head import DistillHeadCIFAR
from models.ops import ResNetBasicblock, OPS, NAS_BENCH_201
from utils.genotypes import Struct... | Cream/CDARTS/benchmark201/models/cdarts_controller.py/0 | {
"file_path": "Cream/CDARTS/benchmark201/models/cdarts_controller.py",
"repo_id": "Cream",
"token_count": 6852
} | 295 |
""" CNN cell for architecture search """
import torch
import torch.nn as nn
from lib.models import ops
class SearchCell(nn.Module):
""" Cell for search
Each edge is mixed and continuous relaxed.
"""
def __init__(self, n_nodes, C_pp, C_p, C, reduction_p, reduction, is_slim=False):
"""
A... | Cream/CDARTS/lib/models/search_cells.py/0 | {
"file_path": "Cream/CDARTS/lib/models/search_cells.py",
"repo_id": "Cream",
"token_count": 962
} | 296 |
# 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
import torch
import numpy as np
import torch.nn.functional as F
from copy import deepcopy
# Prioritized Path Board
class PrioritizedBoard():
... | Cream/Cream/lib/models/PrioritizedBoard.py/0 | {
"file_path": "Cream/Cream/lib/models/PrioritizedBoard.py",
"repo_id": "Cream",
"token_count": 2414
} | 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
import os
import shutil
import argparse
import datetime
import _init_paths
from lib.config import cfg
parser = argparse.ArgumentParser(descript... | Cream/Cream/tools/main.py/0 | {
"file_path": "Cream/Cream/tools/main.py",
"repo_id": "Cream",
"token_count": 872
} | 298 |
"""
Implements the knowledge distillation loss, proposed in deit
"""
import torch
from torch.nn import functional as F
class DistillationLoss(torch.nn.Module):
"""
This module wraps a standard criterion and adds an extra knowledge distillation loss by
taking a teacher model prediction and using it as addi... | Cream/EfficientViT/classification/losses.py/0 | {
"file_path": "Cream/EfficientViT/classification/losses.py",
"repo_id": "Cream",
"token_count": 1171
} | 299 |
_base_ = 'coco_instance.py'
dataset_type = 'LVISV1Dataset'
data_root = 'data/lvis_v1/'
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
_delete_=True,
type='ClassBalancedDataset',
oversample_thr=1e-3,
dataset=dict(
type=dataset_type,
ann_... | Cream/EfficientViT/downstream/configs/_base_/datasets/lvis_v1_instance.py/0 | {
"file_path": "Cream/EfficientViT/downstream/configs/_base_/datasets/lvis_v1_instance.py",
"repo_id": "Cream",
"token_count": 375
} | 300 |
# model settings
norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
model = dict(
type='RepPointsV2Detector',
pretrained=None,
backbone=dict(
type='SwinTransformer',
embed_dim=96,
depths=[2, 2, 6, 2],
num_heads=[3, 6, 12, 24],
window_size=7,
mlp_rat... | Cream/EfficientViT/downstream/configs/_base_/models/reppointsv2_swin_bifpn.py/0 | {
"file_path": "Cream/EfficientViT/downstream/configs/_base_/models/reppointsv2_swin_bifpn.py",
"repo_id": "Cream",
"token_count": 1538
} | 301 |
# Copyright (c) Open-MMLab. All rights reserved.
import io
import os
import os.path as osp
import pkgutil
import time
import warnings
from collections import OrderedDict
from importlib import import_module
from tempfile import TemporaryDirectory
import torch
import torchvision
from torch.optim import Optimizer
from to... | Cream/EfficientViT/downstream/mmcv_custom/checkpoint.py/0 | {
"file_path": "Cream/EfficientViT/downstream/mmcv_custom/checkpoint.py",
"repo_id": "Cream",
"token_count": 7949
} | 302 |
"""
Implements the knowledge distillation loss
"""
import torch
from torch.nn import functional as F
class DistillationLoss(torch.nn.Module):
"""
This module wraps a standard criterion and adds an extra knowledge distillation loss by
taking a teacher model prediction and using it as additional supervision... | Cream/MiniViT/Mini-DeiT/losses.py/0 | {
"file_path": "Cream/MiniViT/Mini-DeiT/losses.py",
"repo_id": "Cream",
"token_count": 1151
} | 303 |
# only for evaluation
DATA:
IMG_SIZE: 384
MODEL:
TYPE: swin
NAME: swin_base_patch4_window12_384
SWIN:
EMBED_DIM: 128
DEPTHS: [ 2, 2, 18, 2 ]
NUM_HEADS: [ 4, 8, 16, 32 ]
WINDOW_SIZE: 12
TEST:
CROP: False | Cream/MiniViT/Mini-Swin/configs/swin_base_patch4_window12_384.yaml/0 | {
"file_path": "Cream/MiniViT/Mini-Swin/configs/swin_base_patch4_window12_384.yaml",
"repo_id": "Cream",
"token_count": 115
} | 304 |
import torch
from timm.scheduler.cosine_lr import CosineLRScheduler
from timm.scheduler.step_lr import StepLRScheduler
from timm.scheduler.scheduler import Scheduler
def build_scheduler(config, optimizer, n_iter_per_epoch):
num_steps = int(config.TRAIN.EPOCHS * n_iter_per_epoch)
warmup_steps = int(config.TRAI... | Cream/MiniViT/Mini-Swin/lr_scheduler.py/0 | {
"file_path": "Cream/MiniViT/Mini-Swin/lr_scheduler.py",
"repo_id": "Cream",
"token_count": 1849
} | 305 |
MODEL:
NAME: TinyViT-21M-224to384
TYPE: tiny_vit
DROP_PATH_RATE: 0.1
TINY_VIT:
DEPTHS: [ 2, 2, 6, 2 ]
NUM_HEADS: [ 3, 6, 12, 18 ]
WINDOW_SIZES: [ 12, 12, 24, 12 ]
EMBED_DIMS: [96, 192, 384, 576]
DATA:
IMG_SIZE: 384
TRAIN:
EPOCHS: 30
WARMUP_EPOCHS: 5
WEIGHT_DECAY: 1e-8
BASE_LR: 2e-0... | Cream/TinyViT/configs/higher_resolution/tiny_vit_21m_224to384.yaml/0 | {
"file_path": "Cream/TinyViT/configs/higher_resolution/tiny_vit_21m_224to384.yaml",
"repo_id": "Cream",
"token_count": 258
} | 306 |
import os
import multiprocessing
import tempfile
class _Writer:
def __init__(self, path, rank):
self.msg_queue = multiprocessing.Queue()
self.worker = multiprocessing.Process(
target=self._async_manager_worker_fn,
args=(self.msg_queue, path, rank),
)
self.wo... | Cream/TinyViT/data/augmentation/manager.py/0 | {
"file_path": "Cream/TinyViT/data/augmentation/manager.py",
"repo_id": "Cream",
"token_count": 2518
} | 307 |
# --------------------------------------------------------
# TinyViT Data Builder
# Copyright (c) 2022 Microsoft
# Based on the code: Swin Transformer
# (https://github.com/microsoft/swin-transformer)
# Adapted for TinyVIT
# --------------------------------------------------------
import os
import torch
import numpy... | Cream/TinyViT/data/build.py/0 | {
"file_path": "Cream/TinyViT/data/build.py",
"repo_id": "Cream",
"token_count": 3717
} | 308 |
# --------------------------------------------------------
# TinyViT Utils
# Copyright (c) 2022 Microsoft
# --------------------------------------------------------
import torch
from torch import nn
class RemapLayer(nn.Module):
def __init__(self, fname):
super().__init__()
with open(fname) as fin... | Cream/TinyViT/models/remap_layer.py/0 | {
"file_path": "Cream/TinyViT/models/remap_layer.py",
"repo_id": "Cream",
"token_count": 279
} | 309 |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import json
import os
import util.misc as utils
try:
from panopticapi.evaluation import pq_compute
except ImportError:
pass
class PanopticEvaluator(object):
def __init__(self, ann_file, ann_folder, output_dir="panoptic_eval"):
... | Cream/iRPE/DETR-with-iRPE/datasets/panoptic_eval.py/0 | {
"file_path": "Cream/iRPE/DETR-with-iRPE/datasets/panoptic_eval.py",
"repo_id": "Cream",
"token_count": 653
} | 310 |
# 2D RPE Operators
## Build iRPE operators implemented by CUDA.
Although iRPE can be implemented by PyTorch native functions, the backward speed of PyTorch index function is very slow. We implement CUDA operators for more efficient training and recommend to build it. `nvcc` is necessary to build CUDA operators.
```bas... | Cream/iRPE/DETR-with-iRPE/rpe_ops/README.md/0 | {
"file_path": "Cream/iRPE/DETR-with-iRPE/rpe_ops/README.md",
"repo_id": "Cream",
"token_count": 447
} | 311 |
# How to equip iRPE ?
The implementation of iRPE (image relative position encoding) contains two parts, namely python part `irpe.py` and C++/CUDA part `rpe_ops`. The python code `irpe.py` is the basic part to implement the four kinds of relative position encoding mappings, and the C++/CUDA code `rpe_ops` accelerate th... | Cream/iRPE/HOW_TO_EQUIP_iRPE.md/0 | {
"file_path": "Cream/iRPE/HOW_TO_EQUIP_iRPE.md",
"repo_id": "Cream",
"token_count": 1355
} | 312 |
from .ra_sampler import RASampler
| CvT/lib/dataset/samplers/__init__.py/0 | {
"file_path": "CvT/lib/dataset/samplers/__init__.py",
"repo_id": "CvT",
"token_count": 12
} | 313 |
include version.py
include setup.py | anomalydetector/MANIFEST.in/0 | {
"file_path": "anomalydetector/MANIFEST.in",
"repo_id": "anomalydetector",
"token_count": 9
} | 314 |
from msanomalydetector.spectral_residual import SpectralResidual
from msanomalydetector.util import MAX_RATIO, THRESHOLD, MAG_WINDOW, SCORE_WINDOW, DetectMode
__all__ = ['SpectralResidual', 'MAX_RATIO', 'THRESHOLD', 'MAG_WINDOW', 'SCORE_WINDOW', 'DetectMode']
| anomalydetector/msanomalydetector/__init__.py/0 | {
"file_path": "anomalydetector/msanomalydetector/__init__.py",
"repo_id": "anomalydetector",
"token_count": 97
} | 315 |
import unittest
import numpy as np
from msanomalydetector import boundary_utils
class TestBoundaryUnit(unittest.TestCase):
def test_calculate_boundary_unit(self):
data = [139809.0, 139706.0, 140562.0, 140534.0, 140568.0, 139934.0, 139392.0, 141714.0, 144167.0, 147127.0,
147450.0, 147991.0,... | anomalydetector/tests/test_boundary_utils.py/0 | {
"file_path": "anomalydetector/tests/test_boundary_utils.py",
"repo_id": "anomalydetector",
"token_count": 3115
} | 316 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Iterable, List, Mapping, OrderedDict
from archai.common import utils
class DelimitedText:
def __init__(self) -> None:
self._data: OrderedDict[str, List[str]] = OrderedDict()
def add_from_file(self, filepath:... | archai/archai/common/delimited_text.py/0 | {
"file_path": "archai/archai/common/delimited_text.py",
"repo_id": "archai",
"token_count": 1100
} | 317 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Any, Callable, Dict, List, Optional, Tuple
import cv2
import lmdb
import msgpack
import numpy as np
import torch
from torch.utils.data import Dataset
from archai.common.ordered_dict_logger import OrderedDictLogger
logger = O... | archai/archai/datasets/cv/tensorpack_lmdb_dataset_provider_utils.py/0 | {
"file_path": "archai/archai/datasets/cv/tensorpack_lmdb_dataset_provider_utils.py",
"repo_id": "archai",
"token_count": 3076
} | 318 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Optional
from archai.datasets.nlp.tokenizer_utils.bbpe_tokenizer import BbpeTokenizer
class Gpt2Tokenizer(BbpeTokenizer):
"""GPT-2 based tokenizer."""
def __init__(
self,
save_path: str,
voca... | archai/archai/datasets/nlp/tokenizer_utils/gpt2_tokenizer.py/0 | {
"file_path": "archai/archai/datasets/nlp/tokenizer_utils/gpt2_tokenizer.py",
"repo_id": "archai",
"token_count": 1146
} | 319 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import numpy as np
import yaml
from tqdm import tqdm
from archai.discrete_search.api.archai_model import ArchaiModel
from archai.discrete_search.api.model_evaluator import (
... | archai/archai/discrete_search/api/search_objectives.py/0 | {
"file_path": "archai/archai/discrete_search/api/search_objectives.py",
"repo_id": "archai",
"token_count": 5982
} | 320 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import statistics
from typing import Any, Dict, List, Optional, Union
import torch
from archai.discrete_search.evaluators.pt_profiler_utils.pt_profiler_model import (
ProfilerModel,
)
def profile(
model: torch.nn.Module,
forward_a... | archai/archai/discrete_search/evaluators/pt_profiler_utils/pt_profiler_eval.py/0 | {
"file_path": "archai/archai/discrete_search/evaluators/pt_profiler_utils/pt_profiler_eval.py",
"repo_id": "archai",
"token_count": 1209
} | 321 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from collections import OrderedDict
from typing import Any, Callable, Dict, Union
from archai.discrete_search.search_spaces.config.discrete_choice import DiscreteChoice
def flatten_dict(odict: Dict[str, Any]) -> dict:
"""Flatten a nested d... | archai/archai/discrete_search/search_spaces/config/utils.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/config/utils.py",
"repo_id": "archai",
"token_count": 1576
} | 322 |
import torch
from torch import nn
from typing import Optional
from transformers.models.gpt2.configuration_gpt2 import GPT2Config
from archai.discrete_search.search_spaces.config import ArchConfig
try:
from flash_attn.ops.fused_dense import FusedDense
except ImportError:
FusedDense = None
from .utils import ge... | archai/archai/discrete_search/search_spaces/nlp/tfpp/mixed_op.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/nlp/tfpp/mixed_op.py",
"repo_id": "archai",
"token_count": 1117
} | 323 |
# Copied from https://github.com/HazyResearch/state-spaces/blob/06dbbdfd0876501a7f12bf3262121badbc7658af/src/models/hippo/hippo.py
""" Definitions of A and B matrices for various HiPPO operators. """
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from scipy import special as ss
... | archai/archai/discrete_search/search_spaces/nlp/tfpp/ops/ssm_utils/hippo.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/nlp/tfpp/ops/ssm_utils/hippo.py",
"repo_id": "archai",
"token_count": 4948
} | 324 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
#
# Copyright (c) 2018, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0.
from typing import Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
class AdaptiveEmbedding(nn.Module):
def __i... | archai/archai/discrete_search/search_spaces/nlp/transformer_flex/models/mem_transformer_utils/adaptive_embedding.py/0 | {
"file_path": "archai/archai/discrete_search/search_spaces/nlp/transformer_flex/models/mem_transformer_utils/adaptive_embedding.py",
"repo_id": "archai",
"token_count": 1644
} | 325 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from itertools import chain
from typing import Optional
import numpy as np
import torch
from archai.common.ordered_dict_logger import OrderedDictLogger
from archai.onnx.config_utils.codegen_onnx_config import CodeGenOnnxConfig
from archai.onnx.... | archai/archai/onnx/export.py/0 | {
"file_path": "archai/archai/onnx/export.py",
"repo_id": "archai",
"token_count": 2647
} | 326 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from typing import Any
def rgetattr(obj: Any, attr: str, *args) -> Any:
"""Recursively get an attribute from an object.
This function allows accessing nested attributes by separating each level with a dot (e.g., "attr1... | archai/archai/quantization/quantization_utils.py/0 | {
"file_path": "archai/archai/quantization/quantization_utils.py",
"repo_id": "archai",
"token_count": 684
} | 327 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from collections import defaultdict
from typing import Dict, List
import numpy as np
import archai.supergraph.algos.divnas.analyse_activations as aa
from archai.supergraph.nas.cell import Cell
from archai.supergraph.nas.operations import Op, Ze... | archai/archai/supergraph/algos/divnas/divnas_cell.py/0 | {
"file_path": "archai/archai/supergraph/algos/divnas/divnas_cell.py",
"repo_id": "archai",
"token_count": 2032
} | 328 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Optional
from overrides import overrides
from archai.supergraph.algos.manual.manual_evaluater import ManualEvaluater
from archai.supergraph.algos.manual.manual_searcher import ManualSearcher
from archai.supergraph.nas.arch_tr... | archai/archai/supergraph/algos/manual/manual_exp_runner.py/0 | {
"file_path": "archai/archai/supergraph/algos/manual/manual_exp_runner.py",
"repo_id": "archai",
"token_count": 353
} | 329 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import List, Optional
import torch
from overrides import overrides
from torch import Tensor
from archai.supergraph.nas.arch_params import ArchParams
from archai.supergraph.nas.model_desc import OpDesc
from archai.supergraph.nas.oper... | archai/archai/supergraph/algos/nasbench101/nasbench101_op.py/0 | {
"file_path": "archai/archai/supergraph/algos/nasbench101/nasbench101_op.py",
"repo_id": "archai",
"token_count": 702
} | 330 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .providers.cifar10_provider import Cifar10Provider
from .providers.cifar100_provider import Cifar100Provider
from .providers.fashion_mnist_provider import FashionMnistProvider
from .providers.flower102_provider import Flower102Provider
from ... | archai/archai/supergraph/datasets/__init__.py/0 | {
"file_path": "archai/archai/supergraph/datasets/__init__.py",
"repo_id": "archai",
"token_count": 183
} | 331 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from overrides import overrides
from torchvision import datasets
from torchvision.transforms import transforms
from archai.common import utils
from archai.common.config import Config
from archai.supergraph.datasets.dataset_provider im... | archai/archai/supergraph/datasets/providers/imagenet_provider.py/0 | {
"file_path": "archai/archai/supergraph/datasets/providers/imagenet_provider.py",
"repo_id": "archai",
"token_count": 1349
} | 332 |
"""
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the implementations on the web is copy-paste from
torchvision's resnet and has w... | archai/archai/supergraph/models/resnet_paper.py/0 | {
"file_path": "archai/archai/supergraph/models/resnet_paper.py",
"repo_id": "archai",
"token_count": 2228
} | 333 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import List, Optional, Tuple
from overrides import EnforceOverrides
from torch import nn
from archai.supergraph.nas.cell import Cell
from archai.supergraph.nas.model import Model
from archai.supergraph.nas.model_desc import CellDesc... | archai/archai/supergraph/nas/finalizers.py/0 | {
"file_path": "archai/archai/supergraph/nas/finalizers.py",
"repo_id": "archai",
"token_count": 2019
} | 334 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Iterator, List, Optional
from torch.optim.lr_scheduler import _LRScheduler
from torch.optim.optimizer import Optimizer
from archai.common.utils import zip_eq
class OptimSched:
"""Holds the optimizer and scheduler"""
... | archai/archai/supergraph/utils/multi_optim.py/0 | {
"file_path": "archai/archai/supergraph/utils/multi_optim.py",
"repo_id": "archai",
"token_count": 1135
} | 335 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from dataclasses import dataclass, field
from transformers.training_args import TrainingArguments
@dataclass
class DistillerTrainingArguments(TrainingArguments):
"""Training arguments for distillation-based training.
This class extend... | archai/archai/trainers/nlp/hf_training_args.py/0 | {
"file_path": "archai/archai/trainers/nlp/hf_training_args.py",
"repo_id": "archai",
"token_count": 262
} | 336 |
__include__: 'darts.yaml' # just use darts defaults
nas:
search:
model_desc:
num_edges_to_sample: 2 # number of edges each node will take input from
eval:
model_desc:
num_edges_to_sample: 2
| archai/confs/algos/random.yaml/0 | {
"file_path": "archai/confs/algos/random.yaml",
"repo_id": "archai",
"token_count": 87
} | 337 |
dataset:
name: svhn
autoaug:
model:
type: wresnet28_10
loader:
aug: fa_reduced_svhn
cutout: 20
batch: 512
epochs: 200
lr_schedule:
type: 'cosine'
warmup:
multiplier: 4
epochs: 5
optimizer:
type: sgd
lr: 0.01
nesterov: True
decay: 0.0005 | archai/confs/aug/wresnet28x10_svhn_b512.yaml/0 | {
"file_path": "archai/confs/aug/wresnet28x10_svhn_b512.yaml",
"repo_id": "archai",
"token_count": 157
} | 338 |
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Runs an interactive bash within the container
docker run --rm \
--gpus all \
--name nvidia22.10-archai \
--shm-size=10g \
--ipc=host \
--ulimit memlock=-1 \
--ulimit stack=67108864 \
-e NCCL_P2P_LEVEL=NVL... | archai/docker/run_container.sh/0 | {
"file_path": "archai/docker/run_container.sh",
"repo_id": "archai",
"token_count": 149
} | 339 |
<jupyter_start><jupyter_text>Multi-node SearchThis notebook and accompanying code shows how to run an[Archai](https://github.com/microsoft/archai/) Neural Architecture Search (NAS) using an [AzureMachine Learning Workspace](https://ml.azure.com/) with partial training of models (on a GPUcluster) providing validation ac... | archai/docs/advanced_guide/cloud/azure/notebooks/multi_node_search/multi_node_search.ipynb/0 | {
"file_path": "archai/docs/advanced_guide/cloud/azure/notebooks/multi_node_search/multi_node_search.ipynb",
"repo_id": "archai",
"token_count": 6162
} | 340 |
import argparse
from archai.discrete_search.algos.evolution_pareto import EvolutionParetoSearch
from archai.discrete_search.api.search_objectives import SearchObjectives
from archai.discrete_search.evaluators.nlp.parameters import NonEmbeddingParamsProxy
from archai.discrete_search.evaluators.nlp.transformer_flex_late... | archai/docs/advanced_guide/cloud/azure/notebooks/text_generation/src/search.py/0 | {
"file_path": "archai/docs/advanced_guide/cloud/azure/notebooks/text_generation/src/search.py",
"repo_id": "archai",
"token_count": 1577
} | 341 |
Documentation
=============
The Archai project welcomes contributions through the implementation of documentation files using Sphinx and RST. If you are interested in contributing to the project in this way, please follow these steps:
#. Ensure that Sphinx is installed. You can install it using ``pip install archai[d... | archai/docs/contributing/documentation.rst/0 | {
"file_path": "archai/docs/contributing/documentation.rst",
"repo_id": "archai",
"token_count": 544
} | 342 |
from typing import List, Optional
from overrides import overrides
import numpy as np
import torch
import re
from torch import nn
from archai.discrete_search.api import ArchaiModel
import json
from random import Random
from archai.discrete_search.api import DiscreteSearchSpace
from model import MyModel
class CNNSear... | archai/docs/getting_started/notebooks/discrete_search/cnn_search_space.py/0 | {
"file_path": "archai/docs/getting_started/notebooks/discrete_search/cnn_search_space.py",
"repo_id": "archai",
"token_count": 2089
} | 343 |
<jupyter_start><jupyter_text>Quantizing Models with PyTorchQuantizing an NLP-based model in PyTorch involves reducing the precision of the model's parameters to improve its inference speed and reduce its memory footprint. The process involves converting floating-point parameters to integers and can be implemented by ad... | archai/docs/getting_started/notebooks/nlp/torch_quantization.ipynb/0 | {
"file_path": "archai/docs/getting_started/notebooks/nlp/torch_quantization.ipynb",
"repo_id": "archai",
"token_count": 955
} | 344 |
Natural Language Processing
===========================
Parameters
----------
.. automodule:: archai.discrete_search.evaluators.nlp.parameters
:members:
:undoc-members:
Transformer-Flex Latency
------------------------
.. automodule:: archai.discrete_search.evaluators.nlp.transformer_flex_latency
:members:... | archai/docs/reference/api/archai.discrete_search.evaluators.nlp.rst/0 | {
"file_path": "archai/docs/reference/api/archai.discrete_search.evaluators.nlp.rst",
"repo_id": "archai",
"token_count": 161
} | 345 |
ONNX
====
.. toctree::
:maxdepth: 2
archai.onnx.config_utils
archai.onnx.optimization_utils
ONNX Forward
------------
.. automodule:: archai.onnx.onnx_forward
:members:
:undoc-members:
ONNX Loader
-----------
.. automodule:: archai.onnx.onnx_loader
:members:
:undoc-members:
Export
------
..... | archai/docs/reference/api/archai.onnx.rst/0 | {
"file_path": "archai/docs/reference/api/archai.onnx.rst",
"repo_id": "archai",
"token_count": 248
} | 346 |
ShakeShake
==========
Shake ResNet
------------
.. automodule:: archai.supergraph.models.shakeshake.shake_resnet
:members:
:undoc-members:
Shake ResNext
-------------
.. automodule:: archai.supergraph.models.shakeshake.shake_resnext
:members:
:undoc-members:
ShakeShake
----------
.. automodule:: archa... | archai/docs/reference/api/archai.supergraph.models.shakeshake.rst/0 | {
"file_path": "archai/docs/reference/api/archai.supergraph.models.shakeshake.rst",
"repo_id": "archai",
"token_count": 149
} | 347 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import json
from lm_eval.evaluator import make_table
from lm_eval.tasks import ALL_TASKS, TASK_REGISTRY
from lm_eval_harness.lm_eval_evaluator import evaluate_wrapper
from lm_eval_harness.lm_eval_hf_model import HFEvalModel
from ... | archai/research/lm_eval_harness/evaluate_with_lm_eval_harness.py/0 | {
"file_path": "archai/research/lm_eval_harness/evaluate_with_lm_eval_harness.py",
"repo_id": "archai",
"token_count": 1551
} | 348 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import json
import os
import natsort
from lm_eval.evaluator import evaluate
from lm_eval_harness.lm_eval_hf_model import HFEvalModel
from lm_eval_harness.tasks.human_eval import HumanEval
from transformers import AutoTokenizer, C... | archai/scripts/eval/hf/evaluate_human_eval.py/0 | {
"file_path": "archai/scripts/eval/hf/evaluate_human_eval.py",
"repo_id": "archai",
"token_count": 1280
} | 349 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import os
import pathlib
from archai.common import utils
from archai.common.config import Config
# To upload dataset on Azure, tar the folder and use command like
# azcopy copy "H:\dataroot_cloud\ImageNet.tar" "https://archai.bl... | archai/scripts/supergraph/download_datasets/pt_install.py/0 | {
"file_path": "archai/scripts/supergraph/download_datasets/pt_install.py",
"repo_id": "archai",
"token_count": 1665
} | 350 |
import json
import pickle
import tensorflow as tf
from archai.common import utils
dataset_file = utils.full_path("~/dataroot/nasbench_ds/nasbench_only108.tfrecord")
records = []
for serialized_row in tf.python_io.tf_record_iterator(dataset_file):
module_hash, epochs, raw_adjacency, raw_operations, raw_metrics =... | archai/scripts/supergraph/nasbench101/tfrecord2pkl.py/0 | {
"file_path": "archai/scripts/supergraph/nasbench101/tfrecord2pkl.py",
"repo_id": "archai",
"token_count": 328
} | 351 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
from transformers import (
AutoTokenizer,
CodeGenConfig,
CodeGenForCausalLM,
TrainingArguments,
)
from archai.datasets.nlp.fast_hf_dataset_provider import (
FastDataCollatorForLanguageModeling,
FastHfData... | archai/scripts/trainers/hf/train_codegen.py/0 | {
"file_path": "archai/scripts/trainers/hf/train_codegen.py",
"repo_id": "archai",
"token_count": 1288
} | 352 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import os
import sys
import json
import statistics
from status import get_all_status_entities, update_status_entity
CONNECTION_NAME = 'MODEL_STORAGE_CONNECTION_STRING'
STDEV_THRESHOLD = 10 # redo any runs that have a stdev > ... | archai/tasks/face_segmentation/aml/azure/find_unsteady_runs.py/0 | {
"file_path": "archai/tasks/face_segmentation/aml/azure/find_unsteady_runs.py",
"repo_id": "archai",
"token_count": 1290
} | 353 |
#!/bin/bash
mkdir -p /home/archai/experiment
export INPUT_DATASET=/home/archai/datasets/FaceSynthetics
if [[ ! -d $INPUT_DATASET ]]; then
mkdir -p $INPUT_DATASET
pushd $INPUT_DATASET
azcopy copy https://nasfacemodels.blob.core.windows.net/downloads/099000.zip .
unzip 099000.zip
rm -rf 099000.zip
... | archai/tasks/face_segmentation/aml/docker/quantizer/run.sh/0 | {
"file_path": "archai/tasks/face_segmentation/aml/docker/quantizer/run.sh",
"repo_id": "archai",
"token_count": 269
} | 354 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
def calc_pareto_frontier(points):
""" Given an array of points where the first 2 coordinates define a 2D point
return a sorted version of those points and a list of array indexes into that
sorted list that define t... | archai/tasks/face_segmentation/aml/util/pareto.py/0 | {
"file_path": "archai/tasks/face_segmentation/aml/util/pareto.py",
"repo_id": "archai",
"token_count": 254
} | 355 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import sys
import itertools
from pathlib import Path
from argparse import ArgumentParser
from typing import List, Optional
from archai.common.config import Config
from archai.common.store import ArchaiStore
from archai.datasets.cv.face... | archai/tasks/face_segmentation/search.py/0 | {
"file_path": "archai/tasks/face_segmentation/search.py",
"repo_id": "archai",
"token_count": 2679
} | 356 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import io
from typing import Dict, List, Optional, Tuple, Union
import os
os.environ["OMP_NUM_THREADS"] = "1"
import statistics
from time import perf_counter
import onnxruntime as rt
import torch
from archai.discrete_search.api.archai_model i... | archai/tasks/facial_landmark_detection/latency.py/0 | {
"file_path": "archai/tasks/facial_landmark_detection/latency.py",
"repo_id": "archai",
"token_count": 1910
} | 357 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Generates new tokens with a pre-trained model.")
parser.ad... | archai/tasks/text_generation/generate_text.py/0 | {
"file_path": "archai/tasks/text_generation/generate_text.py",
"repo_id": "archai",
"token_count": 575
} | 358 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import shutil
from archai.datasets.cv.mnist_dataset_provider import MnistDatasetProvider
def test_mnist_dataset_provider():
# make sure tests can run in parallel and not clobber each other's dataroot.
unique_data_root = 't... | archai/tests/datasets/cv/test_mnist_dataset_provider.py/0 | {
"file_path": "archai/tests/datasets/cv/test_mnist_dataset_provider.py",
"repo_id": "archai",
"token_count": 422
} | 359 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import pytest
from archai.discrete_search.algos.random_search import RandomSearch
@pytest.fixture(scope="session")
def output_dir(tmp_path_factory):
return tmp_path_factory.mktemp("out_evo")
def test_random_search(output_dir, ... | archai/tests/discrete_search/algos/test_random_search.py/0 | {
"file_path": "archai/tests/discrete_search/algos/test_random_search.py",
"repo_id": "archai",
"token_count": 314
} | 360 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.