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/examples/nas/legacy/oneshot/darts/datasets.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
import torch
from torchvision import transforms
from torchvision.datasets import CIFAR10
class Cutout(object):
def __init__(self, length):
self.length = length
def __call__(self, img):
h, w = img.size... | 1,654 | 28.035088 | 101 | py |
nni | nni-master/examples/nas/legacy/oneshot/darts/model.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from collections import OrderedDict
import torch
import torch.nn as nn
import ops
from nni.retiarii.nn.pytorch import LayerChoice, InputChoice
class AuxiliaryHead(nn.Module):
""" Auxiliary head in 2/3 place of network to let the gradient ... | 6,337 | 38.36646 | 126 | py |
nni | nni-master/examples/nas/legacy/oneshot/darts/ops.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
class DropPath(nn.Module):
def __init__(self, p=0.):
"""
Drop path with probability.
Parameters
----------
p : float
Probability of an path to be zeroed... | 4,134 | 29.182482 | 95 | py |
nni | nni-master/examples/nas/legacy/oneshot/darts/retrain.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import time
from argparse import ArgumentParser
import torch
import torch.nn as nn
from torch.utils.tensorboard import SummaryWriter
import datasets
import utils
from model import CNN
from nni.nas.pytorch.utils import AverageMete... | 6,043 | 37.012579 | 99 | py |
nni | nni-master/examples/nas/legacy/oneshot/darts/search.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import logging
import time
from argparse import ArgumentParser
import torch
import torch.nn as nn
import datasets
from model import CNN
from nni.nas.pytorch.callbacks import ArchitectureCheckpoint, LRSchedulerCallback
from utils imp... | 2,882 | 37.959459 | 118 | py |
nni | nni-master/examples/nas/legacy/oneshot/darts/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
def accuracy(output, target, topk=(1,)):
""" Computes the precision@k for the specified values of k """
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
# one-hot cas... | 630 | 29.047619 | 72 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas-tf/datasets.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import tensorflow as tf
def get_dataset():
(x_train, y_train), (x_valid, y_valid) = tf.keras.datasets.cifar10.load_data()
x_train, x_valid = x_train / 255.0, x_valid / 255.0
train_set = (x_train, y_train)
valid_set = (x_valid, y_... | 359 | 29 | 82 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas-tf/macro.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import tensorflow as tf
from tensorflow.keras import Model, Sequential
from tensorflow.keras.layers import (
AveragePooling2D,
BatchNormalization,
Conv2D,
Dense,
Dropout,
GlobalAveragePooling2D,
MaxPool2D,
ReLU,
... | 4,663 | 31.615385 | 84 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas-tf/micro.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import tensorflow as tf
from tensorflow.keras import Model, Sequential
from tensorflow.keras.layers import (
AveragePooling2D,
BatchNormalization,
Conv2D,
Dense,
Dropout,
GlobalAveragePooling2D,
MaxPool2D,
ReLU,
... | 5,902 | 32.350282 | 120 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas-tf/search.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from tensorflow.keras.losses import Reduction, SparseCategoricalCrossentropy
from tensorflow.keras.optimizers import SGD
from nni.algorithms.nas.tensorflow import enas
import datasets
from macro import GeneralNetwork
from micro import MicroNet... | 1,066 | 28.638889 | 80 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas-tf/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import tensorflow as tf
def accuracy_metrics(y_true, logits):
return {'enas_acc': accuracy(y_true, logits)}
def accuracy(y_true, logits):
# y_true: shape=(batch_size) or (batch_size,1), type=integer
# logits: shape=(batch_size, num... | 623 | 30.2 | 64 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas/README.md | [Documentation](https://nni.readthedocs.io/en/latest/NAS/ENAS.html)
| 68 | 33.5 | 67 | md |
nni | nni-master/examples/nas/legacy/oneshot/enas/README_zh_CN.md | [文档](https://nni.readthedocs.io/zh/latest/NAS/ENAS.html)
| 57 | 28 | 56 | md |
nni | nni-master/examples/nas/legacy/oneshot/enas/datasets.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from torchvision import transforms
from torchvision.datasets import CIFAR10
def get_dataset(cls):
MEAN = [0.49139968, 0.48215827, 0.44653124]
STD = [0.24703233, 0.24348505, 0.26158768]
transf = [
transforms.RandomCrop(32, pa... | 900 | 30.068966 | 101 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas/macro.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch.nn as nn
from nni.nas.pytorch import mutables
from ops import FactorizedReduce, ConvBranch, PoolBranch
class ENASLayer(mutables.MutableScope):
def __init__(self, key, prev_labels, in_filters, out_filters):
super().__i... | 3,245 | 36.310345 | 102 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas/micro.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
import torch.nn.functional as F
from nni.nas.pytorch import mutables
from ops import FactorizedReduce, StdConv, SepConvBN, Pool
class AuxiliaryHead(nn.Module):
def __init__(self, in_channels, num_classes)... | 7,054 | 35.365979 | 127 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas/ops.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
class StdConv(nn.Module):
def __init__(self, C_in, C_out):
super(StdConv, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(C_in, C_out, 1, stride=1, padding=0, bias=False),... | 3,401 | 30.794393 | 103 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas/search.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import time
from argparse import ArgumentParser
import torch
import torch.nn as nn
import datasets
from macro import GeneralNetwork
from micro import MicroNetwork
from nni.algorithms.nas.pytorch import enas
from nni.nas.pytorch.c... | 3,434 | 41.407407 | 122 | py |
nni | nni-master/examples/nas/legacy/oneshot/enas/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
def accuracy(output, target, topk=(1,)):
""" Computes the precision@k for the specified values of k """
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
... | 832 | 25.870968 | 72 | py |
nni | nni-master/examples/nas/legacy/oneshot/naive-tf/train.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
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 tens... | 2,663 | 28.6 | 100 | py |
nni | nni-master/examples/nas/legacy/oneshot/naive/README.md | This is a naive example that demonstrates how to use NNI interface to implement a NAS search space. | 99 | 99 | 99 | md |
nni | nni-master/examples/nas/legacy/oneshot/naive/README_zh_CN.md | 这是一个简单示例,演示如何使用 NNI 接口实现 NAS 搜索空间。 | 34 | 34 | 34 | md |
nni | nni-master/examples/nas/legacy/oneshot/naive/train.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
from nni.nas.pytorch.mutables import LayerChoice, InputChoice
from nni.algorithms.nas.pytorch.darts import DartsTrainer
class Net(nn.Module):
def __init__(... | 2,501 | 32.810811 | 115 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/examples/nas/legacy/oneshot/pfld/datasets.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import cv2
import os
import numpy as np
from torch.utils import data
class PFLDDatasets(data.Dataset):
""" Dataset to manage the data loading, augmentation and generation. ... | 1,884 | 28.920635 | 79 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/export.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import argparse
import onnx
import onnxsim
import os
import torch
from lib.builder import search_space
from lib.ops import PRIMITIVES
from nni.algorithms.nas.pytorch.fbnet import ... | 2,141 | 29.169014 | 75 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/retrain.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import argparse
import logging
import os
import time
import torch
import torchvision
import numpy as np
from datasets import PFLDDatasets
from lib.builder import search_space
fro... | 9,821 | 30.280255 | 79 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/train.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import argparse
import logging
import os
import torch
import torchvision
import numpy as np
from datasets import PFLDDatasets
from lib.builder import search_space
from lib.ops im... | 6,486 | 30.1875 | 80 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/builder.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
search_space = {
# multi-stage definition for candidate layers
# here two stages are defined for PFLD searching
"stages": {
"stage_0": {
"ops": [
... | 1,480 | 25.446429 | 65 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/ops.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
# Basic primitives as the network path
PRIMITIVES = {
"skip": lambda c_in, c_out, stride, **kwargs: Identi... | 13,000 | 27.448578 | 78 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/subnet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import torch
import torch.nn as nn
from lib.ops import (
MBBlock,
SeparableConv,
SingleOperation,
StemBlock,
conv_bn,
)
from torch.nn import init
INIT_CH = 16... | 4,663 | 27.266667 | 75 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/supernet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import torch
import torch.nn as nn
from lib.ops import (
MBBlock,
SeparableConv,
StemBlock,
choice_blocks,
conv_bn,
)
from nni.nas.pytorch import mutables
from... | 4,639 | 27.121212 | 79 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/trainer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import os
import time
import torch
import numpy as np
from nni.algorithms.nas.pytorch.fbnet import FBNetTrainer
from nni.nas.pytorch.utils import AverageMeter
from .utils import ... | 10,392 | 33.875839 | 79 | py |
nni | nni-master/examples/nas/legacy/oneshot/pfld/lib/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import, division, print_function
import torch
import numpy as np
import torch.nn as nn
def accuracy(preds, target):
"""
Calculate the NME (Normalized Mean Error).
Parameters
----------
pred... | 3,397 | 25.546875 | 79 | py |
nni | nni-master/examples/nas/legacy/oneshot/proxylessnas/datasets.py | import os
import numpy as np
import torch.utils.data
import torchvision.transforms as transforms
import torchvision.datasets as datasets
def get_split_list(in_dim, child_num):
in_dim_list = [in_dim // child_num] * child_num
for _i in range(in_dim % child_num):
in_dim_list[_i] += 1
return in_dim_lis... | 6,483 | 33.489362 | 107 | py |
nni | nni-master/examples/nas/legacy/oneshot/proxylessnas/main.py | import json
import logging
import os
import sys
from argparse import ArgumentParser
import torch
from torchvision import transforms
from nni.retiarii.fixed import fixed_arch
import datasets
from model import SearchMobileNet
from putils import LabelSmoothingLoss, accuracy, get_parameters
from retrain import Retrain
l... | 7,519 | 51.957746 | 124 | py |
nni | nni-master/examples/nas/legacy/oneshot/proxylessnas/model.py | import torch
import nni.retiarii.nn.pytorch as nn
import math
import ops
import putils
from nni.retiarii.nn.pytorch import LayerChoice
class SearchMobileNet(nn.Module):
def __init__(self,
width_stages=[24,40,80,96,192,320],
n_cell_stages=[4,4,4,4,4,1],
stride_sta... | 5,490 | 41.898438 | 145 | py |
nni | nni-master/examples/nas/legacy/oneshot/proxylessnas/ops.py | from collections import OrderedDict
from nni.retiarii.serializer import basic_unit
import torch
import nni.retiarii.nn.pytorch as nn
from putils import get_same_padding, build_activation
OPS = {
'Identity': lambda in_C, out_C, stride: IdentityLayer(in_C, out_C, ops_order='weight_bn_act'),
'Zero': lambda in_C... | 11,821 | 34.289552 | 116 | py |
nni | nni-master/examples/nas/legacy/oneshot/proxylessnas/putils.py | import torch
import nni.retiarii.nn.pytorch as nn
def get_parameters(model, keys=None, mode='include'):
if keys is None:
for name, param in model.named_parameters():
yield param
elif mode == 'include':
for name, param in model.named_parameters():
flag = False
... | 3,458 | 31.027778 | 94 | py |
nni | nni-master/examples/nas/legacy/oneshot/proxylessnas/retrain.py | import time
import math
from datetime import timedelta
import torch
from torch import nn as nn
from nni.nas.pytorch.utils import AverageMeter
def cross_entropy_with_label_smoothing(pred, target, label_smoothing=0.1):
logsoftmax = nn.LogSoftmax()
n_classes = pred.size(1)
# convert to one-hot
target = to... | 7,941 | 42.398907 | 102 | py |
nni | nni-master/examples/nas/legacy/oneshot/spos/README.md | [Documentation](https://nni.readthedocs.io/en/latest/NAS/SPOS.html)
| 68 | 33.5 | 67 | md |
nni | nni-master/examples/nas/legacy/oneshot/spos/README_zh_CN.md | [文档](https://nni.readthedocs.io/zh/latest/NAS/SPOS.html) | 56 | 56 | 56 | md |
nni | nni-master/examples/nas/legacy/oneshot/spos/blocks.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import nni.retiarii.nn.pytorch as nn
class ShuffleNetBlock(nn.Module):
"""
When stride = 1, the block receives input with 2 * inp channels. Otherwise inp channels.
"""
def __init__(self, inp, oup, mid_channels, ksi... | 3,424 | 36.637363 | 103 | py |
nni | nni-master/examples/nas/legacy/oneshot/spos/evaluation.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import argparse
import logging
import random
import numpy as np
import torch
import torch.nn as nn
import torchvision.transforms as transforms
import torchvision.datasets as datasets
from nni.retiarii import fixed_arch
from nni.retiari... | 6,700 | 41.681529 | 135 | py |
nni | nni-master/examples/nas/legacy/oneshot/spos/network.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import pickle
import re
import torch
import nni.retiarii.nn.pytorch as nn
from nni.retiarii.nn.pytorch import LayerChoice
from nni.retiarii.serializer import model_wrapper
from blocks import ShuffleNetBlock, ShuffleXceptionBlock
@mo... | 5,108 | 36.021739 | 114 | py |
nni | nni-master/examples/nas/legacy/oneshot/spos/search.py | import time
import json
import random
import logging
import argparse
import numpy as np
import torch
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import nni
from nn_meter import load_latency_predictor
import nni.retiarii.nn.pytorch as nn
import nni.retiarii.strategy as strategy
f... | 8,238 | 41.035714 | 135 | py |
nni | nni-master/examples/nas/legacy/oneshot/spos/supernet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import logging
import random
import numpy as np
import torch
import torch.nn as nn
import torchvision.transforms as transforms
import torchvision.datasets as datasets
from nni.retiarii.oneshot.pytorch import SinglePathTrainer
fr... | 3,838 | 46.395062 | 108 | py |
nni | nni-master/examples/nas/legacy/oneshot/spos/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
import numpy as np
import PIL
class CrossEntropyLabelSmooth(nn.Module):
def __init__(self, num_classes, epsilon):
super(CrossEntropyLabelSmooth, self).__init__()
self.num_classes = num_cla... | 2,289 | 31.714286 | 134 | py |
nni | nni-master/examples/nas/legacy/pdarts/README.md | [Documentation](https://nni.readthedocs.io/en/latest/NAS/PDARTS.html)
| 70 | 34.5 | 69 | md |
nni | nni-master/examples/nas/legacy/pdarts/README_zh_CN.md | [文档](https://nni.readthedocs.io/zh/latest/NAS/PDARTS.html)
| 59 | 29 | 58 | md |
nni | nni-master/examples/nas/legacy/pdarts/search.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import sys
import time
from argparse import ArgumentParser
import torch
import torch.nn as nn
from nni.nas.pytorch.callbacks import ArchitectureCheckpoint
from nni.algorithms.nas.pytorch.pdarts import PdartsTrainer
# prevent it ... | 2,764 | 37.402778 | 100 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/darts_example.py | # copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import time
from argparse import ArgumentParser
import torch
import torch.nn as nn
import datasets
from nni.nas.pytorch.callbacks import ArchitectureCheckpoint, LRSchedulerCallback
from nni.algorithms.nas.pytorch.darts import Dar... | 2,166 | 39.12963 | 114 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/darts_stack_cells.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch.nn as nn
from nni.nas.pytorch.search_space_zoo.darts_ops import DropPath
class DartsStackedCells(nn.Module):
"""
builtin Darts Search Space
Compared to Darts example, DartsSearchSpace removes Auxiliary Head, which
i... | 2,843 | 32.857143 | 118 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/datasets.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
import torch
from torchvision import transforms
from torchvision.datasets import CIFAR10
class Cutout(object):
def __init__(self, length):
self.length = length
def __call__(self, img):
h, w = img.size... | 1,654 | 28.035088 | 101 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/enas_macro_example.py | import torch
import logging
import torch.nn as nn
import torch.nn.functional as F
from argparse import ArgumentParser
from torchvision import transforms
from torchvision.datasets import CIFAR10
from nni.nas.pytorch import mutables
from nni.algorithms.nas.pytorch import enas
from utils import accuracy, reward_accuracy... | 3,455 | 38.272727 | 118 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/enas_micro_example.py | import torch
import logging
import torch.nn as nn
import torch.nn.functional as F
from argparse import ArgumentParser
from torchvision import transforms
from torchvision.datasets import CIFAR10
from nni.algorithms.nas.pytorch import enas
from utils import accuracy, reward_accuracy
from nni.nas.pytorch.callbacks impor... | 4,681 | 34.740458 | 118 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/nasbench201.py | import argparse
import json
import logging
import os
import pprint
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from nni.algorithms.nas.pytorch.darts import DartsTrainer
from nni.algorithms.nas.pytorch import enas
from nni... | 9,127 | 43.31068 | 132 | py |
nni | nni-master/examples/nas/legacy/search_space_zoo/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
def accuracy(output, target, topk=(1,)):
""" Computes the precision@k for the specified values of k """
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
... | 829 | 25.774194 | 72 | py |
nni | nni-master/examples/nas/legacy/textnas/README.md | # TextNAS: A Neural Architecture Search Space tailored for Text Representation
TextNAS by MSRA. Official Release.
[Paper link](https://arxiv.org/abs/1912.10729)
## Preparation
Prepare the word vectors and SST dataset, and organize them in data directory as shown below:
```
textnas
├── data
│ ├── sst
│ │ └── ... | 1,235 | 23.72 | 139 | md |
nni | nni-master/examples/nas/legacy/textnas/README_zh_CN.md | # TextNAS: A Neural Architecture Search Space tailored for Text Representation
TextNAS 由 MSRA 提出 正式版本。
[论文链接](https://arxiv.org/abs/1912.10729)
## 准备
准备词向量和 SST 数据集,并按如下结构放到 data 目录中:
```
textnas
├── data
│ ├── sst
│ │ └── trees
│ │ ├── dev.txt
│ │ ├── test.txt
│ │ └── train.txt
│ └... | 881 | 16.64 | 118 | md |
nni | nni-master/examples/nas/legacy/textnas/dataloader.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import os
import pickle
from collections import Counter
import numpy as np
import torch
from torch.utils import data
logger = logging.getLogger("nni.textnas")
class PTBTree:
WORD_TO_WORD_MAPPING = {
"{": "-LCB-",
... | 11,631 | 33.619048 | 102 | py |
nni | nni-master/examples/nas/legacy/textnas/model.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
import torch
import torch.nn as nn
from nni.nas.pytorch import mutables
from ops import ConvBN, LinearCombine, AvgPool, MaxPool, RNN, Attention, BatchNorm
from utils import GlobalMaxPool, GlobalAvgPool
class Layer(mutables.M... | 4,130 | 36.899083 | 124 | py |
nni | nni-master/examples/nas/legacy/textnas/ops.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn.functional as F
from torch import nn
from utils import get_length, INF
class Mask(nn.Module):
def forward(self, seq, mask):
# seq: (N, C, L)
# mask: (N, L)
seq_mask = torch.unsqueeze(mas... | 7,418 | 35.014563 | 115 | py |
nni | nni-master/examples/nas/legacy/textnas/retrain.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import sys
import os
import logging
import pickle
import shutil
import random
import math
import time
import datetime
import argparse
import distutils.util
import numpy as np
import torch
from torch import nn
from torch import optim
from torch.... | 18,074 | 32.659218 | 121 | py |
nni | nni-master/examples/nas/legacy/textnas/run_retrain.sh | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
export PYTHONPATH="$(pwd)"
python3 -u retrain.py \
--train_ratio=1.0 \
--valid_ratio=1.0 \
--min_count=1 \
--is_mask=True \
--is_binary=True \
--child_lr_decay_scheme="cosine" \
--data_path="data" \
--class_num=2 \
--child_opti... | 958 | 22.390244 | 44 | sh |
nni | nni-master/examples/nas/legacy/textnas/search.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import os
import random
from argparse import ArgumentParser
from itertools import cycle
import numpy as np
import torch
import torch.nn as nn
from nni.algorithms.nas.pytorch.enas import EnasMutator, EnasTrainer
from nni.nas.pytor... | 3,679 | 39.888889 | 118 | py |
nni | nni-master/examples/nas/legacy/textnas/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import torch
import torch.nn as nn
INF = 1E10
EPS = 1E-12
logger = logging.getLogger("nni.textnas")
def get_length(mask):
length = torch.sum(mask, 1)
length = length.long().cpu()
return length
class GlobalAvgPool... | 1,669 | 23.558824 | 88 | py |
nni | nni-master/examples/nas/legacy/transformer/README.md | # Tuning Transformer with Retiarii
This demo is adapted from PyTorch Transformer tutorial.
Here, we show how we use functions provided by retiarii to tune Transformer's hyper-parameters, in order to achieve better performance.
This demo is tested with PyTorch 1.9, torchtext == 0.10, and nni == 2.4.
Please change the c... | 1,352 | 66.65 | 382 | md |
nni | nni-master/examples/nas/legacy/transformer/retiarii_transformer_demo.py | ###############################################################
# This demo is adapted from PyTorch Transformer tutorial <https://pytorch.org/tutorials/beginner/transformer_tutorial.html>
# Here we show how we use functions provided by retiarii to tune Transformer's hyper-parameters,
# in order to achieve better perfor... | 8,448 | 39.620192 | 123 | py |
nni | nni-master/examples/trials/README.md | # How to write a Trial running on NNI?
*Trial receive the hyper-parameter/architecture configure from Tuner, and send intermediate result to Assessor and final result to Tuner.*
So when user want to write a Trial running on NNI, she/he should:
**1)Have an original Trial could run**,
Trial's code could be any machin... | 9,233 | 31.4 | 141 | md |
nni | nni-master/examples/trials/README_zh_CN.md | # 如何在 NNI 中实现 Trial 的代码?
*Trial 从 Tuner 中接收超参和架构配置,并将中间结果发送给 Assessor,最终结果发送给Tuner 。*
当用户需要在 NNI 上运行 Trial 时,需要:
**1) 写好原始的训练代码**。
Trial 的代码可以是任何能在本机运行的机器学习代码。 这里使用 `mnist-keras. py` 作为示例:
```python
import argparse
import logging
import keras
import numpy as np
from keras import backend as K
from keras.datasets im... | 8,671 | 29.86121 | 136 | md |
nni | nni-master/examples/trials/auto-gbdt/config.yml | searchSpaceFile: search_space.json
trialCommand: python3 main.py
trialConcurrency: 1
maxTrialNumber: 10
tuner:
name: TPE
classArgs:
optimize_mode: minimize
trainingService: # For other platforms, check mnist-pytorch example
platform: local
| 251 | 21.909091 | 68 | yml |
nni | nni-master/examples/trials/auto-gbdt/config_metis.yml | # The search space of Metis tuner is slightly different from TPE and others.
# See Metis tuner' doc for details: https://nni.readthedocs.io/en/stable/Tuner/MetisTuner.html
searchSpace:
num_leaves:
_type: choice
_value: [31, 28, 24, 20]
learning_rate:
_type: choice
_value: [0.01, 0.05, 0.1, 0.2]
ba... | 551 | 23 | 94 | yml |
nni | nni-master/examples/trials/auto-gbdt/config_windows.yml | searchSpaceFile: search_space.json
trialCommand: python main.py
trialConcurrency: 1
maxTrialNumber: 10
tuner:
name: TPE
classArgs:
optimize_mode: minimize
trainingService: # For other platforms, check mnist-pytorch example
platform: local
| 250 | 21.818182 | 68 | yml |
nni | nni-master/examples/trials/auto-gbdt/main.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... | 3,636 | 31.473214 | 128 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/parse_result_csv.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import pandas as pd
import sys
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
def generate_perf_report(result_file_name):
"""
Generate a performance report.
The input result_file_name should be the path of the ... | 7,585 | 44.42515 | 130 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/runbenchmark_nni.sh | #!/bin/bash
time=$(date "+%Y%m%d%H%M%S")
installation='automlbenchmark'
outdir="results_$time"
benchmark='nnivalid' # 'nnismall' 'nnismall-regression' 'nnismall-binary' 'nnismall-multiclass'
serialize=true # if false, run all experiments together in background
mkdir $outdir $outdir/scorelogs $outdir/r... | 1,780 | 30.245614 | 101 | sh |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/setup.sh | #!/bin/bash
# download automlbenchmark repository
if [ ! -d './automlbenchmark' ] ; then
git clone https://github.com/openml/automlbenchmark.git --branch v1.6 --depth 1
fi
# install dependencies
pip3 install -r automlbenchmark/requirements.txt
pip3 install -r requirements.txt --ignore-installed
| 303 | 26.636364 | 83 | sh |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/config.yaml | ---
input_dir: '{user}/data'
frameworks:
definition_file:
- '{root}/resources/frameworks.yaml'
- '{user}/frameworks.yaml'
benchmarks:
definition_dir:
- '{user}/benchmarks'
- '{root}/resources/benchmarks'
constraints_file:
- '{user}/constraints.yaml'
- '{root}/resources/constraints.y... | 325 | 18.176471 | 41 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/frameworks.yaml | ---
NNI:
module: extensions.NNI
version: 'stable'
project: https://github.com/microsoft/nni
# type in ['TPE', 'Random', 'Anneal', 'Evolution', 'SMAC', 'GPTuner', 'MetisTuner', 'DNGOTuner', 'Hyperband', 'BOHB']
# arch_type in ['random_forest', 'mlp']
# limit_type in ['time', 'ntrials']
# limit must be an integer... | 1,746 | 17.585106 | 117 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/benchmarks/nnismall-binary.yaml | ---
- name: __defaults__
folds: 2
cores: 2
max_runtime_seconds: 300
- name: Australian
openml_task_id: 146818
- name: blood-transfusion
openml_task_id: 10101
- name: christine
openml_task_id: 168908
- name: credit-g
openml_task_id: 31
- name: kc1
openml_task_id: 3917
- name: kr-vs-kp
openml_ta... | 411 | 12.733333 | 26 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/benchmarks/nnismall-multiclass.yaml | ---
- name: __defaults__
folds: 2
cores: 2
max_runtime_seconds: 300
- name: car
openml_task_id: 146821
- name: cnae-9
openml_task_id: 9981
- name: dilbert
openml_task_id: 168909
- name: fabert
openml_task_id: 168910
- name: jasmine
openml_task_id: 168911
- name: mfeat-factors
openml_task_id: 1... | 402 | 12.433333 | 26 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/benchmarks/nnismall-regression.yaml | ---
- name: __defaults__
folds: 2
cores: 2
max_runtime_seconds: 300
- name: cholesterol
openml_task_id: 2295
- name: liver-disorders
openml_task_id: 52948
- name: kin8nm
openml_task_id: 2280
- name: cpu_small
openml_task_id: 4883
- name: titanic_2
openml_task_id: 211993
- name: boston
openm... | 418 | 12.966667 | 26 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/benchmarks/nnismall.yaml | ---
- name: __defaults__
folds: 2
cores: 2
max_runtime_seconds: 300
- name: cholesterol
openml_task_id: 2295
- name: liver-disorders
openml_task_id: 52948
- name: kin8nm
openml_task_id: 2280
- name: cpu_small
openml_task_id: 4883
- name: titanic_2
openml_task_id: 211993
- name: boston
openm... | 1,079 | 12.846154 | 26 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/benchmarks/nnivalid.yaml | ---
#for doc purpose using <placeholder:default_value> syntax when it applies.
#FORMAT: global defaults are defined in config.yaml
- name: __dummy-task
enabled: false # actual default is `true` of course...
openml_task_id: 0
metric: # the first metric in the task list will be optimized against and used for the ... | 1,300 | 28.568182 | 226 | yaml |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
def run(*args, **kwargs):
from .exec import run
return run(*args, **kwargs)
| 158 | 21.714286 | 38 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/exec.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
from .tuners import NNITuner
from .run_experiment import *
from amlb.benchmark import TaskConfig
from amlb.data import Dataset
from amlb.results import save_predictions_to_file
from amlb.utils import Timer
log = logging.getLogg... | 3,118 | 42.319444 | 144 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/run_experiment.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .architectures.run_random_forest import *
from .architectures.run_mlp import *
def run_experiment(dataset, config, tuner, log):
if 'arch_type' not in config.framework_params:
raise RuntimeError('framework.yaml does not have a "... | 684 | 33.25 | 88 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/tuners.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import yaml
import importlib
import nni
from nni.runtime.config import get_config_file
from nni.utils import MetricType
from nni.tuner import Tuner
from nni.runtime.msg_dispatcher_base import MsgDispatcherBase
from amlb.benchmark im... | 5,793 | 35.904459 | 93 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_mlp.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import sklearn
import time
import numpy as np
from sklearn.impute import SimpleImputer
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder, StandardScaler
from sklearn.pipeline import Pipe... | 6,044 | 38 | 146 | py |
nni | nni-master/examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_random_forest.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import sklearn
import time
import numpy as np
from sklearn.impute import SimpleImputer
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OrdinalEncoder
from sklearn.pipeline import Pipeline
from sklea... | 7,175 | 39.772727 | 146 | py |
nni | nni-master/examples/trials/benchmarking/hyperband/config_hyperband.yml | advisor:
name: Hyperband
classArgs:
optimize_mode: maximize
#R: the maximum trial budget (could be the number of mini-batches or epochs) can be
# allocated to a trial. Each trial should use trial budget to control how long it runs.
R: 60
#eta: proportion of discarded trials
eta: 3
#... | 492 | 22.47619 | 93 | yml |
nni | nni-master/examples/trials/benchmarking/hyperband/main.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
A test for hyperband, using nasbench201. So it need install the dependencies for nasbench201 at first.
"""
import argparse
import logging
import random
import time
import nni
from nni.utils import merge_parameter
from nni.nas.benchmarks.nasb... | 1,725 | 31.566038 | 102 | py |
nni | nni-master/examples/trials/cifar10_pytorch/README.md | This example requires pytorch.
pytorch install package should be chosen based on python version and cuda version.
Here is an example of the environment python==3.5 and cuda == 8.0, then using the following commands to install pytorch:
python3 -m pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-l... | 370 | 60.833333 | 120 | md |
nni | nni-master/examples/trials/cifar10_pytorch/README_zh_CN.md | 此示例需要安装 Pytorch。 Pytorch 安装包需要选择所基于的 Python 和 CUDA 版本。
以下是 python==3.5 和 cuda == 8.0 下的环境示例,使用下列命令来安装 Pytorch: python3 -m pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-linux_x86_64.whl python3 -m pip install torchvision | 246 | 81.333333 | 190 | md |
nni | nni-master/examples/trials/cifar10_pytorch/adl.Dockerfile | # Dockerfile for building AdaptDL-enabled CIFAR10 image
# Set docker build context to current folder
FROM pytorch/pytorch:1.4-cuda10.1-cudnn7-runtime
RUN pip install nni adaptdl tensorboard
COPY ./ /cifar10
| 210 | 22.444444 | 55 | Dockerfile |
nni | nni-master/examples/trials/cifar10_pytorch/config.yml | searchSpaceFile: search_space.json
trialCommand: python3 main.py
trialGpuNumber: 1
trialConcurrency: 4
maxTrialNumber: 10
tuner:
name: TPE
classArgs:
optimize_mode: maximize
trainingService: # For other platforms, check mnist-pytorch example
platform: local
maxTrialNumberPerGpu: 2
useActiveGpu: false # ... | 554 | 36 | 134 | yml |
nni | nni-master/examples/trials/cifar10_pytorch/config_adl.yml | authorName: default
experimentName: example_pytorch_cifar10
trialConcurrency: 1
maxExecDuration: 100h
maxTrialNum: 10
nniManagerIp: {replace_with_your_ip}
trainingServicePlatform: adl
searchSpacePath: search_space_adl.json
logCollection: http
#choice: true, false
useAnnotation: false
tuner:
#choice: TPE, Random, Anne... | 1,253 | 30.35 | 87 | yml |
nni | nni-master/examples/trials/cifar10_pytorch/config_windows.yml | searchSpaceFile: search_space.json
trialCommand: python main.py
trialGpuNumber: 1
trialConcurrency: 4
maxTrialNumber: 10
tuner:
name: TPE
classArgs:
optimize_mode: maximize
trainingService: # For other platforms, check mnist-pytorch example
platform: local
maxTrialNumberPerGpu: 2
useActiveGpu: false # N... | 553 | 35.933333 | 134 | yml |