Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
nni | nni-master/docs/templates/relbar.html | {%- if nav_bar_tabs and pagename != 'index' %}
<nav class="md-tabs" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
{%- block rootrellink %}
{%- if theme_master_doc %}
<li class="md-tabs__item">
<a href="{{ pathto(master_doc)|... | 1,032 | 34.62069 | 100 | html |
nni | nni-master/docs/templates/sidebar.html | <nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a href="{{ pathto(master_doc)|e }}" title="{{ docstitle|striptags|e }}" class="md-nav__button md-logo">
<img src="{{ pathto('_static/img/nni-icon.svg', 1) }}" alt="{{ html_title }} logo" ... | 645 | 39.375 | 112 | html |
nni | nni-master/docs/tools/chineselink.py | """
This is to keep Chinese doc update to English doc. Should be run regularly.
There is no sane way to check the contents though. PR review should enforce contributors to update the corresponding translation.
See https://github.com/microsoft/nni/issues/4298 for discussion.
Under docs, run
python tools/chineselin... | 3,044 | 32.833333 | 129 | py |
nni | nni-master/docs/tools/restoremd.py | import os
import shutil
from pathlib import Path
for root, dirs, files in os.walk('archive_en_US'):
root = Path(root)
for file in files:
moved_root = Path('en_US') / root.relative_to('archive_en_US')
shutil.move(root / file, moved_root / file)
os.remove(moved_root / (Path(file).stem + ... | 329 | 26.5 | 70 | py |
nni | nni-master/docs/tools/translation_patch.py | """
Fix a troublsome translation in sphinx.
Related PR: https://github.com/sphinx-doc/sphinx/pull/10303
"""
import subprocess
from pathlib import Path
import sphinx
sphinx_path = Path(sphinx.__path__[0]) / 'locale/zh_CN/LC_MESSAGES'
po_content = (sphinx_path / 'sphinx.po').read_text()
po_content = po_content.replace... | 524 | 28.166667 | 114 | py |
nni | nni-master/examples/assessors/README.md | # Define your own Assessor
*Assessor receive intermediate result from Trial and decide whether the Trial should be killed. Once the Trial experiment meets the early stop conditions, the assessor will kill the Trial.*
So, if users want to implement a customized Assessor, they only need to:
**1) Inherit an assessor o... | 1,755 | 29.275862 | 189 | md |
nni | nni-master/examples/assessors/README_zh_CN.md | # 自定义 Assessor
*Assessor 从 Trial 中接收中间结果,并决定此 Trial 是否应该终止。 一旦 Trial 满足提前终止条件,Assessor 将终止此 Trial。*
因此,如果要自定义 Assessor,需要:
**1) 继承于 Assessor 基类,创建 Assessor 类**
```python
from nni.assessor import Assessor
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
```
**2) 实现评估 Trial 的函数**
```pyt... | 1,297 | 20.278689 | 181 | md |
nni | nni-master/examples/compression/README.md | # Examples
This folder contains the examples of new compression version (NNI 3.0).
## ./evaluator
If you want to view how to initialize a evaluator you need, please refer this example folder.
| 195 | 23.5 | 93 | md |
nni | nni-master/examples/compression/models.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from pathlib import Path
import torch
import torch.nn.functional as F
from torch.optim import Adam
from torch.optim.lr_scheduler import _LRScheduler
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
from torch... | 3,508 | 34.09 | 100 | py |
nni | nni-master/examples/compression/evaluator/lightning_evaluator.py | """
Create Lightning Evaluator
==========================
To create a lightning evaluator in NNI,
you only need to make minor modifications to your existing code.
Modificatoin in LightningModule
-------------------------------
In ``configure_optimizers``, please using ``nni.trace`` to trace the optimizer and lr sche... | 2,693 | 29.613636 | 116 | py |
nni | nni-master/examples/compression/evaluator/torch_evaluator.py | """
Create Pytorch Native Evaluator
===============================
If you are using a native pytorch training loop to train your model, this example could help you getting start quickly.
In this example, you will learn how to create a pytorch native evaluator step by step.
Prepare ``training_func``
-----------------... | 4,104 | 41.760417 | 161 | py |
nni | nni-master/examples/compression/fusion/pd_fuse.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
This script is an exmaple for how to fuse pruning and distillation.
"""
import pickle
import torch
from examples.compression.models import (
build_resnet18,
prepare_dataloader,
prepare_optimizer,
train,
training_step,
... | 3,249 | 35.111111 | 128 | py |
nni | nni-master/examples/compression/fusion/pqd_fuse.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
This script is an exmaple for how to fuse pruning and distillation.
"""
import pickle
import torch
from examples.compression.models import (
build_resnet18,
prepare_dataloader,
prepare_optimizer,
train,
training_step,
... | 6,838 | 42.56051 | 135 | py |
nni | nni-master/examples/compression/pruning/norm_pruning.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
from examples.compression.models import (
build_resnet18,
prepare_dataloader,
prepare_optimizer,
train,
training_step,
evaluate,
device
)
from nni.compression.pruning import (
L1NormPruner,
L2Nor... | 2,015 | 31.516129 | 100 | py |
nni | nni-master/examples/compression/pruning/scheduled_pruning.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
from examples.compression.models import (
build_resnet18,
prepare_dataloader,
prepare_optimizer,
train,
training_step,
evaluate,
device
)
from nni.compression import TorchEvaluator
from nni.compression.p... | 2,271 | 37.508475 | 100 | py |
nni | nni-master/examples/compression/pruning/slim_pruning.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
from examples.compression.models import (
build_resnet18,
prepare_dataloader,
prepare_optimizer,
train,
training_step,
evaluate,
device
)
from nni.compression import TorchEvaluator
from nni.compression.p... | 1,921 | 35.264151 | 100 | py |
nni | nni-master/examples/compression/pruning/taylor_pruning.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
from examples.compression.models import (
build_resnet18,
prepare_dataloader,
prepare_optimizer,
train,
training_step,
evaluate,
device
)
from nni.compression import TorchEvaluator
from nni.compression.p... | 1,924 | 35.320755 | 100 | py |
nni | nni-master/examples/compression/quantization/bnn_example.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Callable, Union, List
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim import Optimizer
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import... | 6,230 | 34.005618 | 126 | py |
nni | nni-master/examples/compression/quantization/dorefa_example.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from typing import Callable, Union, List, Dict, Tuple
import torch
import torch.nn.functional as F
from torch.optim import Optimizer
from torch.utils.data import DataLoader
from torch import Tensor
from torchvision import datas... | 5,145 | 33.77027 | 108 | py |
nni | nni-master/examples/compression/quantization/lsq_example.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from typing import Callable, Union, List, Dict, Tuple
import torch
import torch.nn.functional as F
from torch.optim import Optimizer
from torch.utils.data import DataLoader
from torch import Tensor
from torchvision import datas... | 6,144 | 35.577381 | 111 | py |
nni | nni-master/examples/compression/quantization/ptq_example.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from typing import Callable, Union, List, Tuple, Any, Dict
import torch
import torch.nn.functional as F
from torch.optim import Optimizer
from torch.utils.data import DataLoader
from torch import Tensor
from torchvision import d... | 5,924 | 34.909091 | 108 | py |
nni | nni-master/examples/compression/quantization/qat_example.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import time
from typing import Callable
import torch
import torch.nn.functional as F
from torch.optim import Optimizer, SGD
from torch.utils.data import DataLoader
from torchvision import transforms
from torch... | 4,526 | 31.568345 | 125 | py |
nni | nni-master/examples/concrete_tracer/concrete_trace_distilbert.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
from transformers import modeling_outputs
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from nni.common.concrete_trace_utils import concrete_trace, ConcreteTracer
def check_equal(a, b):
if type(a) !=... | 1,830 | 31.696429 | 81 | py |
nni | nni-master/examples/concrete_tracer/concrete_trace_yolov3.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import torch
from pytorchyolo import models
from nni.common.concrete_trace_utils import concrete_trace
# The Yolo can be downloaded at https://github.com/eriklindernoren/PyTorch-YOLOv3.git
prefix = 'C:\\Works\\PyTorch-YOLOv3' # repl... | 1,448 | 31.931818 | 118 | py |
nni | nni-master/examples/concrete_tracer/concrete_trace_yolov5.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import torch
from nni.common.concrete_trace_utils import concrete_trace
# Load the YOLO model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
dummy_input = torch.rand(16, 3, 320, 320)
def recompile_from_code(code: str, glob... | 1,318 | 31.975 | 118 | py |
nni | nni-master/examples/feature_engineering/auto-feature-engineering/README.md | **Automatic Feature Engineering in nni**
===
Now we have an [example](https://github.com/SpongebBob/tabular_automl_NNI), which could automaticlly do feature engineering in nni.
These code come from our contributors. And thanks our lovely contributors!
And welcome more and more people to join us!
| 315 | 34.111111 | 134 | md |
nni | nni-master/examples/feature_engineering/auto-feature-engineering/README_zh_CN.md | **NNI 中的自动特征工程** ===
此[示例](https://github.com/SpongebBob/tabular_automl_NNI)在 NNI 中实现了自动特征工程。
代码来自于贡献者。 谢谢可爱的贡献者!
欢迎越来越多的人加入我们!
| 137 | 16.25 | 74 | md |
nni | nni-master/examples/feature_engineering/gbdt_selector/gbdt_selector_test.py | # Copyright (c) Microsoft Corporation
# All rights reserved.
#
# MIT License
#
# 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 rights to ... | 2,558 | 37.772727 | 128 | py |
nni | nni-master/examples/feature_engineering/gradient_feature_selector/benchmark_test.py | # Copyright (c) Microsoft Corporation
# All rights reserved.
#
# MIT License
#
# 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 rights to ... | 5,670 | 37.060403 | 128 | py |
nni | nni-master/examples/feature_engineering/gradient_feature_selector/sklearn_test.py | # Copyright (c) Microsoft Corporation
# All rights reserved.
#
# MIT License
#
# 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 rights to ... | 2,423 | 40.793103 | 128 | py |
nni | nni-master/examples/feature_engineering/gradient_feature_selector/test_memory.py | import os
LIBSVM_DATA = {
"rcv1" : "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/rcv1_train.binary.bz2",
"colon-cancer" : "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/covtype.libsvm.binary.bz2",
"gisette" : "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary... | 1,128 | 40.814815 | 144 | py |
nni | nni-master/examples/feature_engineering/gradient_feature_selector/test_time.py | import os
LIBSVM_DATA = {
"rcv1" : "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/rcv1_train.binary.bz2",
"colon-cancer" : "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/covtype.libsvm.binary.bz2",
"gisette" : "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary... | 1,105 | 39.962963 | 144 | py |
nni | nni-master/examples/model_compress/quantization/bert_quantization_with_ds.py | from pathlib import Path
import argparse
import sys
import numpy as np
import torch
from torch.utils.data import ConcatDataset
import nni
from datasets import load_dataset, load_metric
from transformers import BertTokenizerFast, DataCollatorWithPadding, BertForSequenceClassification, EvalPrediction
from transformer... | 7,875 | 38.577889 | 119 | py |
nni | nni-master/examples/model_compress/quantization/quantization_with_deepspeed.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import sys
from typing import Callable, Union, List, Dict, Tuple
import torch
import torch.nn.functional as F
from torch.optim import Optimizer
from torch.utils.data import DataLoader
from torch import Tensor
from torchvision import datasets, t... | 5,079 | 32.642384 | 108 | py |
nni | nni-master/examples/nas/benchmarks/nasbench101.sh | #!/bin/bash
set -e
if [ -z "${NASBENCHMARK_DIR}" ]; then
NASBENCHMARK_DIR=~/.nni/nasbenchmark
fi
echo "Downloading NAS-Bench-101..."
if [ -f "nasbench_full.tfrecord" ]; then
echo "nasbench_full.tfrecord found. Skip download."
else
wget https://storage.googleapis.com/nasbench/nasbench_full.tfrecord
fi
ech... | 560 | 27.05 | 83 | sh |
nni | nni-master/examples/nas/benchmarks/nasbench201.sh | #!/bin/bash
set -e
if [ -z "${NASBENCHMARK_DIR}" ]; then
NASBENCHMARK_DIR=~/.nni/nasbenchmark
fi
echo "Downloading NAS-Bench-201..."
if [ -f "a.pth" ]; then
echo "a.pth found. Skip download."
else
gdown https://drive.google.com/uc\?id\=1OOfVPpt-lA4u2HJrXbgrRd42IbfvJMyE -O a.pth
fi
echo "Generating databa... | 506 | 24.35 | 85 | sh |
nni | nni-master/examples/nas/benchmarks/nds.sh | #!/bin/bash
set -e
if [ -z "${NASBENCHMARK_DIR}" ]; then
NASBENCHMARK_DIR=~/.nni/nasbenchmark
fi
echo "Downloading NDS..."
if [ -f "data.zip" ]; then
echo "data.zip found. Skip download."
else
wget https://dl.fbaipublicfiles.com/nds/data.zip -O data.zip
fi
unzip data.zip
echo "Generating database..."
rm ... | 488 | 22.285714 | 67 | sh |
nni | nni-master/examples/nas/benchmarks/nlp.sh | #!/bin/bash
set -e
if [ -z "${NASBENCHMARK_DIR}" ]; then
NASBENCHMARK_DIR=~/.nni/nasbenchmark
fi
mkdir -p nlp_data
cd nlp_data
echo "Downloading NLP[1/3] wikitext2_data.zip..."
if [ -f "wikitext2_data.zip" ]; then
echo "wikitext2_data.zip found. Skip download."
else
wget -O wikitext2_data.zip https://git... | 1,437 | 34.95 | 135 | sh |
nni | nni-master/examples/nas/legacy/README.md | # NAS Examples (legacy)
Please note that the examples in this folder are marked as legacy and unmaintained.
For latest examples, please read the [documentation](https://nni.readthedocs.io/en/latest/).
| 203 | 33 | 92 | md |
nni | nni-master/examples/nas/legacy/cdarts/aux_head.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch.nn as nn
class DistillHeadCIFAR(nn.Module):
def __init__(self, C, size, num_classes, bn_affine=False):
"""assuming input size 8x8 or 16x16"""
super(DistillHeadCIFAR, self).__init__()
self.features = nn.... | 3,529 | 33.271845 | 107 | py |
nni | nni-master/examples/nas/legacy/cdarts/config.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
from functools import partial
def get_parser(name):
""" make default formatted parser """
parser = argparse.ArgumentParser(name, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# print default value always
... | 8,123 | 57.869565 | 139 | py |
nni | nni-master/examples/nas/legacy/cdarts/genotypes.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
- 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 col... | 5,279 | 30.616766 | 101 | py |
nni | nni-master/examples/nas/legacy/cdarts/model.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
import torch.nn.functional as F
import ops
import numpy as np
from nni.nas.pytorch import mutables
from utils import parse_results
from aux_head import DistillHeadCIFAR, DistillHeadImagenet, AuxiliaryHeadCIFAR,... | 6,644 | 39.766871 | 118 | py |
nni | nni-master/examples/nas/legacy/cdarts/ops.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
OPS = {
'avg_pool_3x3': lambda C, stride, affine: PoolWithoutBN('avg', C, 3, stride, 1, affine=affine),
'max_pool_3x3': lambda C, stride, affine: PoolWithoutBN('max', C, 3, stride, 1, affine=affine),
... | 5,195 | 31.074074 | 118 | py |
nni | nni-master/examples/nas/legacy/cdarts/retrain.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import logging
import os
import time
from argparse import ArgumentParser
import torch
import torch.nn as nn
import apex # pylint: disable=import-error
import datasets
import utils
from apex.parallel import DistributedDataParallel ... | 6,220 | 38.624204 | 135 | py |
nni | nni-master/examples/nas/legacy/cdarts/run_retrain_cifar.sh | NGPUS=4
SGPU=0
EGPU=$[NGPUS+SGPU-1]
GPU_ID=`seq -s , $SGPU $EGPU`
CUDA_VISIBLE_DEVICES=$GPU_ID python -m torch.distributed.launch --nproc_per_node=$NGPUS retrain.py \
--dataset cifar10 --n_classes 10 --init_channels 36 --stem_multiplier 3 \
--arc_checkpoint 'epoch_31.json' \
--batch_size 128 --workers 1 --l... | 587 | 41 | 100 | sh |
nni | nni-master/examples/nas/legacy/cdarts/run_search_cifar.sh | NGPUS=4
SGPU=0
EGPU=$[NGPUS+SGPU-1]
GPU_ID=`seq -s , $SGPU $EGPU`
CUDA_VISIBLE_DEVICES=$GPU_ID python -m torch.distributed.launch --nproc_per_node=$NGPUS search.py \
--dataset cifar10 --n_classes 10 --init_channels 16 --stem_multiplier 3 \
--batch_size 64 --workers 1 --log_frequency 10 \
--distributed --wor... | 624 | 40.666667 | 99 | sh |
nni | nni-master/examples/nas/legacy/cdarts/search.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import os
import random
import time
import numpy as np
import torch
import torch.nn as nn
import utils
from config import SearchConfig
from datasets.cifar import get_search_datasets
from model import Model
from nni.algorithms.nas... | 2,053 | 40.08 | 126 | py |
nni | nni-master/examples/nas/legacy/cdarts/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import logging
import os
import random
from collections import namedtuple
import numpy as np
import torch
import torch.distributed as dist
import torch.nn as nn
from genotypes import Genotype
from ops import PRIMITIVES
from nni.algo... | 4,309 | 30.459854 | 129 | py |
nni | nni-master/examples/nas/legacy/cdarts/datasets/cifar.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
import torch
import torchvision.datasets as dset
import torchvision.transforms as transforms
from datasets.data_utils import CIFAR10Policy, Cutout
from datasets.data_utils import SubsetDistributedSampler
def data_transforms_... | 4,070 | 35.348214 | 101 | py |
nni | nni-master/examples/nas/legacy/cdarts/datasets/data_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import random
import numpy as np
import torch
import torch.distributed as dist
from PIL import Image, ImageEnhance, ImageOps
from torch.utils.data import Sampler
class SubsetDistributedSampler(Sampler):
"""
Sampler that res... | 16,871 | 41.074813 | 138 | py |
nni | nni-master/examples/nas/legacy/cdarts/datasets/imagenet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import numpy as np
import torch
import torchvision.datasets as dset
import torchvision.transforms as transforms
from datasets.data_utils import ImageNetPolicy
from datasets.data_utils import SubsetDistributedSampler
def _imagenet_da... | 3,441 | 33.079208 | 98 | py |
nni | nni-master/examples/nas/legacy/classic_nas-tf/config_ppo.yml | authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 100h
maxTrialNum: 1000
#choice: local, remote, pai
trainingServicePlatform: local
#please use `nnictl ss_gen` to generate search space file first
searchSpacePath: nni_auto_gen_search_space.json
useAnnotation: False
tuner:
builtinTu... | 439 | 22.157895 | 63 | yml |
nni | nni-master/examples/nas/legacy/classic_nas-tf/config_random_search.yml | authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
#choice: local, remote, pai
trainingServicePlatform: local
#please use `nnictl ss_gen` to generate search space file first
searchSpacePath: nni_auto_gen_search_space.json
useAnnotation: False
tuner:
codeDir: ../.... | 471 | 23.842105 | 63 | yml |
nni | nni-master/examples/nas/legacy/classic_nas-tf/train.py | import argparse
import tensorflow as tf
from tensorflow.keras import Model
from tensorflow.keras.layers import (AveragePooling2D, BatchNormalization, Conv2D, Dense, MaxPool2D)
from tensorflow.keras.losses import Reduction, SparseCategoricalCrossentropy
from tensorflow.keras.optimizers import SGD
import nni
from nni.na... | 4,729 | 35.10687 | 100 | py |
nni | nni-master/examples/nas/legacy/classic_nas/config_ppo.yml | authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 100h
maxTrialNum: 1000
#choice: local, remote, pai
trainingServicePlatform: local
#please use `nnictl ss_gen` to generate search space file first
searchSpacePath: <the_generated_search_space_path>
useAnnotation: False
tuner:
builti... | 442 | 22.315789 | 63 | yml |
nni | nni-master/examples/nas/legacy/classic_nas/config_random_search.yml | authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
#choice: local, remote, pai
trainingServicePlatform: local
#please use `nnictl ss_gen` to generate search space file first
searchSpacePath: <the_generated_search_space_path>
useAnnotation: False
tuner:
codeDir: .... | 474 | 24 | 63 | yml |
nni | nni-master/examples/nas/legacy/classic_nas/mnist.py | """
A deep MNIST classifier using convolutional layers.
This file is a modification of the official pytorch mnist example:
https://github.com/pytorch/examples/blob/master/mnist/main.py
"""
import os
import argparse
import logging
from collections import OrderedDict
import nni
import torch
import torch.nn as nn
impor... | 6,765 | 35.771739 | 87 | py |
nni | nni-master/examples/nas/legacy/cream/Cream.md | [Documentation](https://nni.readthedocs.io/en/latest/NAS/Cream.html)
| 69 | 34 | 68 | md |
nni | nni-master/examples/nas/legacy/cream/Cream_zh_CN.md | [文档](https://nni.readthedocs.io/zh/latest/NAS/Cream.html)
| 58 | 28.5 | 57 | md |
nni | nni-master/examples/nas/legacy/cream/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/examples/nas/legacy/cream/retrain.py | # 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 warnings
import datetime
import torch
import numpy as np
import torch.nn as nn
from torchscope import scope
from torch.utils.ten... | 11,551 | 34.875776 | 124 | py |
nni | nni-master/examples/nas/legacy/cream/test.py | # 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 warnings
import datetime
import torch
import torch.nn as nn
from torch.utils.tensorboard import SummaryWriter
# import timm pac... | 5,718 | 34.968553 | 86 | py |
nni | nni-master/examples/nas/legacy/cream/train.py | # 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 sys
import datetime
import torch
import numpy as np
import torch.nn as nn
# import timm packages
from timm.loss import LabelSmoo... | 7,909 | 35.962617 | 110 | py |
nni | nni-master/examples/nas/legacy/cream/configs/test.yaml | AUTO_RESUME: True
DATA_DIR: './data/imagenet'
MODEL: 'Childnet_Testing'
RESUME_PATH: './experiments/workspace/ckps/42.pth.tar'
SAVE_PATH: './'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 4
NUM_GPU: 2
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
LOCAL_RANK: 0
DATASET:
NUM_CLAS... | 684 | 17.513514 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/train.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: 'Supernet_Training'
RESUME_PATH: './experiments/workspace/train/resume.pth.tar'
SAVE_PATH: './'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
LOCAL_RANK: 0
DATASET:
N... | 941 | 16.773585 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/114.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '112m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
L... | 944 | 17.173077 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/14.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '14m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
LO... | 943 | 17.153846 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/23.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '23m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
LO... | 943 | 17.153846 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/287.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '287m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
L... | 944 | 17.173077 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/43.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '43m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
LO... | 942 | 17.134615 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/481.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '481m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
L... | 944 | 17.173077 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/604.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '604m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
L... | 944 | 17.173077 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/configs/retrain/72.yaml | AUTO_RESUME: False
DATA_DIR: './data/imagenet'
MODEL: '72m_retrain'
RESUME_PATH: './experiments/workspace/retrain/resume.pth.tar'
SAVE_PATH: './experiments/workspace/retrain'
SEED: 42
LOG_INTERVAL: 50
RECOVERY_INTERVAL: 0
WORKERS: 8
NUM_GPU: 8
SAVE_IMAGES: False
AMP: False
OUTPUT: 'None'
EVAL_METRICS: 'prec1'
TTA: 0
LO... | 943 | 17.153846 | 61 | yaml |
nni | nni-master/examples/nas/legacy/cream/lib/config.py | # 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... | 3,544 | 27.58871 | 80 | py |
nni | nni-master/examples/nas/legacy/cream/lib/core/retrain.py | import os
import time
import torch
import torchvision
from collections import OrderedDict
from lib.utils.util import AverageMeter, accuracy, reduce_tensor
def train_epoch(
epoch, model, loader, optimizer, loss_fn, cfg,
lr_scheduler=None, saver=None, output_dir='', use_amp=False,
model_ema=Non... | 4,556 | 32.507353 | 79 | py |
nni | nni-master/examples/nas/legacy/cream/lib/core/test.py | # 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 time
import torch
from collections import OrderedDict
from lib.utils.util import AverageMeter, accuracy, reduce_tensor
def validate(epoc... | 3,099 | 34.227273 | 104 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/blocks/__init__.py | from lib.models.blocks.residual_block import get_Bottleneck, get_BasicBlock
from lib.models.blocks.inverted_residual_block import InvertedResidual | 146 | 72.5 | 75 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/blocks/inverted_residual_block.py | # This file is downloaded from
# https://github.com/rwightman/pytorch-image-models
import torch.nn as nn
from timm.models.layers import create_conv2d
from timm.models.efficientnet_blocks import make_divisible, resolve_se_args, \
SqueezeExcite, drop_path
class InvertedResidual(nn.Module):
""" Inverted residu... | 3,447 | 29.245614 | 79 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/blocks/residual_block.py | # 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 torch.nn as nn
import torch.nn.functional as F
def conv3x3(in_planes, out_planes, stride=1):
"3x3 convolution with paddi... | 2,975 | 27.075472 | 76 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/builders/build_childnet.py | from lib.utils.util import *
from timm.models.efficientnet_blocks import *
class ChildNetBuilder:
def __init__(
self,
channel_multiplier=1.0,
channel_divisor=8,
channel_min=None,
output_stride=32,
pad_type='',
act_layer=None,
... | 7,601 | 40.769231 | 103 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/builders/build_supernet.py | from copy import deepcopy
from lib.utils.builder_util import modify_block_args
from lib.models.blocks import get_Bottleneck, InvertedResidual
from timm.models.efficientnet_blocks import *
from nni.nas.pytorch import mutables
class SuperNetBuilder:
""" Build Trunk Blocks
"""
def __init__(
se... | 8,949 | 40.627907 | 117 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/structures/childnet.py | from lib.utils.builder_util import *
from lib.models.builders.build_childnet import *
from timm.models.layers import SelectAdaptivePool2d
from timm.models.layers.activations import hard_sigmoid
class ChildNet(nn.Module):
def __init__(
self,
block_args,
num_classes=1000,
... | 4,701 | 31.205479 | 77 | py |
nni | nni-master/examples/nas/legacy/cream/lib/models/structures/supernet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Written by Hao Du and Houwen Peng
# email: haodu8-c@my.cityu.edu.hk and houwen.peng@microsoft.com
from lib.utils.builder_util import *
from lib.utils.search_structure_supernet import *
from lib.models.builders.build_supernet import *
from lib.u... | 6,608 | 31.55665 | 98 | py |
nni | nni-master/examples/nas/legacy/cream/lib/utils/builder_util.py | import re
import math
import torch.nn as nn
from copy import deepcopy
from timm.utils import *
from timm.models.layers.activations import Swish
from timm.models.layers import CondConv2d, get_condconv_initializer
def parse_ksize(ss):
if ss.isdigit():
return int(ss)
else:
return [int(k) for k i... | 9,932 | 34.98913 | 112 | py |
nni | nni-master/examples/nas/legacy/cream/lib/utils/flops_table.py | # 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
from ptflops import get_model_complexity_info
class FlopsEst(object):
def __init__(self, model, input_shape=(2, 3, 224, 224), ... | 2,757 | 33.475 | 89 | py |
nni | nni-master/examples/nas/legacy/cream/lib/utils/op_by_layer_dict.py | # 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
# This dictionary is generated from calculating each operation of each layer to quickly search for layers.
# flops_op_dict[which_stage][which_oper... | 1,779 | 41.380952 | 106 | py |
nni | nni-master/examples/nas/legacy/cream/lib/utils/search_structure_supernet.py | # 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,... | 1,830 | 37.145833 | 77 | py |
nni | nni-master/examples/nas/legacy/cream/lib/utils/util.py | # 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 sys
import logging
import torch
import argparse
import torch.nn as nn
from torch import optim as optim
from thop import profile, clever_fo... | 5,776 | 30.917127 | 80 | py |
nni | nni-master/examples/nas/legacy/mnasnet/base_mnasnet.py | from nni.retiarii import basic_unit
import nni.retiarii.nn.pytorch as nn
import warnings
import torch
import torch.nn as torch_nn
import torch.nn.functional as F
from nni.retiarii import model_wrapper
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parents[2]))
# Paper suggests 0.999... | 11,630 | 37.899666 | 124 | py |
nni | nni-master/examples/nas/legacy/mnasnet/mutator.py | import logging
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parents[2]))
from nni.retiarii import Mutator
from base_mnasnet import RegularConv, DepthwiseConv, MobileConv
_logger = logging.getLogger(__name__)
class BlockMutator(Mutator):
def __init__(self, target: str):
... | 2,648 | 40.390625 | 98 | py |
nni | nni-master/examples/nas/legacy/mnasnet/search.py | import os
import sys
import torch
from pathlib import Path
import nni.retiarii.evaluator.pytorch.lightning as pl
from nni.retiarii import serialize
from base_mnasnet import MNASNet
from nni.retiarii.experiment.pytorch import RetiariiExperiment, RetiariiExeConfig
from nni.retiarii.strategy import TPEStrategy
from torch... | 2,325 | 38.423729 | 113 | py |
nni | nni-master/examples/nas/legacy/mnist/search.py | import os
import random
from pathlib import Path
import nni
import torch
import torch.nn.functional as F
# remember to import nni.retiarii.nn.pytorch as nn, instead of torch.nn as nn
import nni.retiarii.nn.pytorch as nn
import nni.retiarii.strategy as strategy
from nni.retiarii import model_wrapper
from nni.retiarii.e... | 5,247 | 34.945205 | 112 | py |
nni | nni-master/examples/nas/legacy/nasbench101/base_ops.py | import math
import torch.nn as nn
def truncated_normal_(tensor, mean=0, std=1):
# https://discuss.pytorch.org/t/implementing-truncated-normal-initializer/4778/15
size = tensor.shape
tmp = tensor.new_empty(size + (4,)).normal_()
valid = (tmp < 2) & (tmp > -2)
ind = valid.max(-1, keepdim=True)[1]
... | 1,774 | 33.134615 | 106 | py |
nni | nni-master/examples/nas/legacy/nasbench101/network.py | import click
import nni
import nni.retiarii.evaluator.pytorch.lightning as pl
import torch.nn as nn
import torchmetrics
from nni.retiarii import model_wrapper, serialize
from nni.retiarii.experiment.pytorch import RetiariiExperiment, RetiariiExeConfig
from nni.retiarii.nn.pytorch import NasBench101Cell
from nni.retiari... | 6,718 | 36.536313 | 123 | py |
nni | nni-master/examples/nas/legacy/nasbench201/base_ops.py | import torch
import torch.nn as nn
OPS_WITH_STRIDE = {
'none': lambda C_in, C_out, stride: Zero(C_in, C_out, stride),
'avg_pool_3x3': lambda C_in, C_out, stride: Pooling(C_in, C_out, stride, 'avg'),
'max_pool_3x3': lambda C_in, C_out, stride: Pooling(C_in, C_out, stride, 'max'),
'conv_3x3': lambda C_i... | 4,999 | 34.971223 | 110 | py |
nni | nni-master/examples/nas/legacy/nasbench201/network.py | import click
import nni
import nni.retiarii.evaluator.pytorch.lightning as pl
import torch.nn as nn
import torchmetrics
from nni.retiarii import model_wrapper, serialize
from nni.retiarii.experiment.pytorch import RetiariiExperiment, RetiariiExeConfig
from nni.retiarii.nn.pytorch import NasBench201Cell
from nni.retiari... | 6,162 | 35.684524 | 128 | py |
nni | nni-master/examples/nas/legacy/notebooks/utils.py | import os
import torch
import pandas as pd
from sklearn.preprocessing import LabelEncoder
from torchvision.datasets.utils import download_url
class TitanicDataset(torch.utils.data.Dataset):
def __init__(self, root: str, train: bool = True):
filename = 'train.csv' if train else 'eval.csv'
if not os... | 1,153 | 35.0625 | 119 | py |
nni | nni-master/examples/nas/legacy/oneshot/darts/README.md | [Documentation](https://nni.readthedocs.io/en/latest/NAS/DARTS.html)
| 69 | 34 | 68 | md |
nni | nni-master/examples/nas/legacy/oneshot/darts/README_zh_CN.md | [文档](https://nni.readthedocs.io/zh/latest/NAS/DARTS.html)
| 58 | 28.5 | 57 | md |