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/tutorials/quantization_speedup.py | """
Speed Up Quantized Model with TensorRT
======================================
Quantization algorithms quantize a deep learning model usually in a simulated way. That is, to simulate the effect of low-bit computation with float32 operators, the tensors are quantized to the targeted bit number and dequantized back t... | 8,548 | 43.295337 | 593 | py |
nni | nni-master/examples/tutorials/hpo_nnictl/config.yaml | search_space:
features:
_type: choice
_value: [ 128, 256, 512, 1024 ]
lr:
_type: loguniform
_value: [ 0.0001, 0.1 ]
momentum:
_type: uniform
_value: [ 0, 1 ]
trial_command: python model.py
trial_code_directory: .
trial_concurrency: 2
max_trial_number: 10
tuner:
name: TPE
class_args:... | 386 | 14.48 | 35 | yaml |
nni | nni-master/examples/tutorials/hpo_nnictl/model.py | """
Port PyTorch Quickstart to NNI
==============================
This is a modified version of `PyTorch quickstart`_.
It can be run directly and will have the exact same result as original version.
Furthermore, it enables the ability of auto tuning with an NNI *experiment*, which will be detailed later.
It is recom... | 3,954 | 30.388889 | 106 | py |
nni | nni-master/examples/tutorials/hpo_quickstart_pytorch/main.py | """
HPO Quickstart with PyTorch
===========================
This tutorial optimizes the model in `official PyTorch quickstart`_ with auto-tuning.
The tutorial consists of 4 steps:
1. Modify the model for auto-tuning.
2. Define hyperparameters' search space.
3. Configure the experiment.
4. Run the experiment.
.. _of... | 5,626 | 35.070513 | 108 | py |
nni | nni-master/examples/tutorials/hpo_quickstart_pytorch/model.py | """
Port PyTorch Quickstart to NNI
==============================
This is a modified version of `PyTorch quickstart`_.
It can be run directly and will have the exact same result as original version.
Furthermore, it enables the ability of auto tuning with an NNI *experiment*, which will be detailed later.
It is recom... | 3,954 | 30.388889 | 106 | py |
nni | nni-master/examples/tutorials/hpo_quickstart_tensorflow/main.py | """
HPO Quickstart with TensorFlow
==============================
This tutorial optimizes the model in `official TensorFlow quickstart`_ with auto-tuning.
The tutorial consists of 4 steps:
1. Modify the model for auto-tuning.
2. Define hyperparameters' search space.
3. Configure the experiment.
4. Run the experiment... | 5,895 | 36.316456 | 108 | py |
nni | nni-master/examples/tutorials/hpo_quickstart_tensorflow/model.py | """
Port TensorFlow Quickstart to NNI
=================================
This is a modified version of `TensorFlow quickstart`_.
It can be run directly and will have the exact same result as original version.
Furthermore, it enables the ability of auto tuning with an NNI *experiment*, which will be detailed later.
It... | 2,988 | 32.58427 | 106 | py |
nni | nni-master/examples/tutorials/scripts/trial_sklearn.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,986 | 32.561798 | 128 | py |
nni | nni-master/nni/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
try:
from .version import __version__ # pylint: disable=import-error
except ModuleNotFoundError:
__version__ = '999.dev0'
from .runtime.log import _init_logger
_init_logger()
from .common.framework import *
from .common.serializer impo... | 908 | 28.322581 | 68 | py |
nni | nni-master/nni/__main__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import base64
import json
import logging
import os
import traceback
from .runtime.msg_dispatcher import MsgDispatcher
from .runtime.msg_dispatcher_base import MsgDispatcherBase
from .tools.package_utils import create_builtin_clas... | 3,013 | 32.865169 | 112 | py |
nni | nni-master/nni/assessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Assessor analyzes trial's intermediate results (e.g., periodically evaluated accuracy on test dataset)
to tell whether this trial can be early stopped or not.
See :class:`Assessor`' specification and ``docs/en_US/assessors.rst`` for details.... | 4,499 | 34.15625 | 121 | py |
nni | nni-master/nni/parameter_expressions.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
'''
parameter_expression.py
'''
import numpy as np
def choice(options, random_state):
'''
options: 1-D array-like or int
random_state: an object of numpy.random.RandomState
'''
return random_state.choice(options)
def rand... | 3,236 | 28.697248 | 91 | py |
nni | nni-master/nni/recoverable.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import os
import nni
class Recoverable:
def __init__(self):
self.recovered_max_param_id = -1
self.recovered_trial_params = {}
def load_checkpoint(self) -> None:
pass
def s... | 1,790 | 33.442308 | 103 | py |
nni | nni-master/nni/trial.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
from typing import Any, cast
from .runtime.env_vars import trial_env_vars
from .runtime.trial_command_channel import get_default_trial_command_channel
from .typehint import Parameters, TrialMetric, ParameterRe... | 4,701 | 27.325301 | 105 | py |
nni | nni-master/nni/tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Tuner is an AutoML algorithm, which generates a new configuration for the next try.
A new trial will run with this configuration.
See :class:`Tuner`' specification and ``docs/en_US/tuners.rst`` for details.
"""
from __future__ import annota... | 9,451 | 40.638767 | 120 | py |
nni | nni-master/nni/typehint.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Types for static checking.
"""
__all__ = ['Parameters', 'SearchSpace', 'TrialMetric', 'TrialRecord', 'ParameterRecord']
from typing import Any, Dict, List, Optional
from typing_extensions import Literal, TypedDict, NotRequired
Parameters ... | 2,460 | 32.712329 | 108 | py |
nni | nni-master/nni/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
from enum import Enum, unique
from pathlib import Path
from schema import And
from . import parameter_expressions
@unique
class OptimizeMode(Enum):
"""Optimize Mode class
if OptimizeMode is 'minimize', it means the tuner n... | 10,130 | 30.858491 | 116 | py |
nni | nni-master/nni/algorithms/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/algorithms/feature_engineering/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/algorithms/feature_engineering/gbdt_selector/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .gbdt_selector import GBDTSelector | 113 | 27.5 | 39 | py |
nni | nni-master/nni/algorithms/feature_engineering/gbdt_selector/gbdt_selector.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 u... | 4,424 | 37.146552 | 100 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .gradient_selector import FeatureGradientSelector | 128 | 31.25 | 54 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/constants.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 u... | 3,624 | 34.891089 | 131 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/fginitialize.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 u... | 21,387 | 33.947712 | 108 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/fgtrain.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 u... | 7,536 | 31.912664 | 100 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/gradient_selector.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 u... | 26,160 | 40.393987 | 108 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/learnability.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 u... | 19,347 | 35.164486 | 111 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/syssettings.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 u... | 1,363 | 44.466667 | 100 | py |
nni | nni-master/nni/algorithms/feature_engineering/gradient_selector/utils.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 u... | 2,802 | 34.481013 | 100 | py |
nni | nni-master/nni/algorithms/hpo/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/algorithms/hpo/batch_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
batch_tuner.py including:
class BatchTuner
"""
import logging
import nni
from nni.common.hpo_utils import validate_search_space
from nni.tuner import Tuner
TYPE = '_type'
CHOICE = 'choice'
VALUE = '_value'
LOGGER = logging.getLogger('... | 4,539 | 29.884354 | 99 | py |
nni | nni-master/nni/algorithms/hpo/dngo_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import warnings
import numpy as np
import torch
from pybnn import DNGO
from torch.distributions import Normal
import nni.parameter_expressions as parameter_expressions
from nni import ClassArgsValidator
from nni.common.hpo_utils ... | 6,141 | 39.675497 | 123 | py |
nni | nni-master/nni/algorithms/hpo/evolution_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
evolution_tuner.py
"""
from __future__ import annotations
import copy
import random
import logging
from collections import deque
import numpy as np
from schema import Schema, Optional
import nni
from nni import ClassArgsValidator
from nni.... | 10,114 | 32.382838 | 131 | py |
nni | nni-master/nni/algorithms/hpo/gridsearch_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Grid search tuner.
For categorical parameters this tuner fully explore all combinations.
For numerical parameters it samples them at progressively decreased intervals.
"""
__all__ = ['GridSearchTuner']
import logging
import math
import nu... | 10,719 | 36.351916 | 123 | py |
nni | nni-master/nni/algorithms/hpo/hyperband_advisor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
hyperband_advisor.py
"""
import copy
import logging
import math
import sys
import numpy as np
from schema import Schema, Optional
import nni
from nni import ClassArgsValidator
from nni.common.hpo_utils import validate_search_space
from nni... | 22,561 | 37.111486 | 133 | py |
nni | nni-master/nni/algorithms/hpo/hyperopt_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
hyperopt_tuner.py
"""
import copy
import logging
import hyperopt as hp
import numpy as np
from schema import Optional, Schema
from nni import ClassArgsValidator
from nni.common.hpo_utils import validate_search_space
from nni.tuner import Tu... | 18,109 | 36.966457 | 130 | py |
nni | nni-master/nni/algorithms/hpo/medianstop_assessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import logging
from schema import Schema, Optional
from typing_extensions import Literal
from nni import ClassArgsValidator
from nni.assessor import Assessor, AssessResult
from nni.utils import extract_scalar... | 4,362 | 35.663866 | 108 | py |
nni | nni-master/nni/algorithms/hpo/pbt_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import logging
import os
import random
import numpy as np
from schema import Schema, Optional
import nni
from nni import ClassArgsValidator
import nni.parameter_expressions
from nni.tuner import Tuner
from nni.utils import OptimizeMo... | 22,018 | 41.101338 | 133 | py |
nni | nni-master/nni/algorithms/hpo/random_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Naive random tuner.
You can specify an integer seed to determine random result.
"""
from __future__ import annotations
__all__ = ['RandomTuner']
import logging
import numpy as np
import schema
from nni import ClassArgsValidator
from nni... | 2,362 | 25.852273 | 90 | py |
nni | nni-master/nni/algorithms/hpo/regularized_evolution_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import logging
import random
from collections import deque
from schema import Schema, Optional
import nni
from nni.tuner import Tuner
from nni import ClassArgsValidator
from nni.utils import OptimizeMode, extract_scalar_reward
logge... | 6,249 | 34.511364 | 96 | py |
nni | nni-master/nni/algorithms/hpo/tpe_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Tree-structured Parzen Estimator (TPE) tuner.
Paper: https://proceedings.neurips.cc/paper/2011/file/86e8f7ab32cfd12577bc2619bc635690-Paper.pdf
Official code: https://github.com/hyperopt/hyperopt/blob/master/hyperopt/tpe.py
This is a slight... | 17,279 | 36.565217 | 122 | py |
nni | nni-master/nni/algorithms/hpo/bohb_advisor/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .bohb_advisor import BOHB, BOHBClassArgsValidator
| 129 | 25 | 54 | py |
nni | nni-master/nni/algorithms/hpo/bohb_advisor/bohb_advisor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
'''
bohb_advisor.py
'''
import sys
import math
import logging
from schema import Schema, Optional
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
from ConfigSpace.read_and_write import pcs_new
import nni
from nni import ClassA... | 35,125 | 42.152334 | 135 | py |
nni | nni-master/nni/algorithms/hpo/bohb_advisor/config_generator.py | # BSD 3-Clause License
# Copyright (c) 2017-2018, ML4AAD
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this
# list of... | 14,287 | 40.414493 | 130 | py |
nni | nni-master/nni/algorithms/hpo/curvefitting_assessor/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .curvefitting_assessor import CurvefittingAssessor, CurvefittingClassArgsValidator
| 162 | 31.6 | 87 | py |
nni | nni-master/nni/algorithms/hpo/curvefitting_assessor/curvefitting_assessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import datetime
from schema import Schema, Optional
from nni import ClassArgsValidator
from nni.assessor import Assessor, AssessResult
from nni.utils import extract_scalar_history
from .model_factory import CurveModel
logger = lo... | 5,829 | 40.056338 | 121 | py |
nni | nni-master/nni/algorithms/hpo/curvefitting_assessor/curvefunctions.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
A family of functions used by CurvefittingAssessor
"""
import numpy as np
all_models = {}
model_para = {}
model_para_num = {}
curve_combination_models = ['vap', 'pow3', 'linear', 'logx_linear', 'dr_hill_zero_background', 'log_power', 'pow4... | 5,115 | 16.225589 | 122 | py |
nni | nni-master/nni/algorithms/hpo/curvefitting_assessor/model_factory.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import numpy as np
from scipy import optimize
from .curvefunctions import * # pylint: disable=wildcard-import,unused-wildcard-import
# Number of curve functions we prepared, more details can be found in "curvefunctions.py"
NUM_OF... | 12,051 | 35.410876 | 126 | py |
nni | nni-master/nni/algorithms/hpo/gp_tuner/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .gp_tuner import GPTuner, GPClassArgsValidator
| 126 | 24.4 | 51 | py |
nni | nni-master/nni/algorithms/hpo/gp_tuner/gp_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
GPTuner is a Bayesian Optimization method where Gaussian Process is used for modeling loss functions.
See :class:`GPTuner` for details.
"""
import warnings
import logging
import numpy as np
from schema import Schema, Optional
from sklearn.... | 9,094 | 38.202586 | 135 | py |
nni | nni-master/nni/algorithms/hpo/gp_tuner/target_space.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Tool class to hold the param-space coordinates (X) and target values (Y).
"""
import numpy as np
import nni.parameter_expressions as parameter_expressions
def _hashable(params):
"""
Transform list params to tuple format. Ensure tha... | 7,924 | 25.773649 | 102 | py |
nni | nni-master/nni/algorithms/hpo/gp_tuner/util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
utility functions and classes for GPTuner
"""
import warnings
import numpy as np
from scipy.stats import norm
from scipy.optimize import minimize
def _match_val_type(vals, bounds):
"""
Update values in the array, to match their cor... | 6,659 | 27.101266 | 96 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .metis_tuner import MetisTuner, MetisClassArgsValidator
| 135 | 26.2 | 60 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/lib_acquisition_function.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
lib_acquisition_function.py
"""
import sys
import numpy
from scipy.stats import norm
from scipy.optimize import minimize
from . import lib_data
def next_hyperparameter_expected_improvement(fun_prediction,
... | 7,591 | 37.343434 | 80 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/lib_constraint_summation.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
lib_constraint_summation.py
"""
import math
import random
from operator import itemgetter
def check_feasibility(x_bounds, lowerbound, upperbound):
'''
This can have false positives.
For examples, parameters can only be 0 or 5,... | 5,040 | 45.247706 | 98 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/lib_data.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import random
def match_val_type(vals, vals_bounds, vals_types):
'''
Update values in the array, to match their corresponding type
'''
vals_new = []
for i, _ in enumerate(vals_types):
if vals_types[i] ==... | 1,528 | 28.980392 | 80 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/metis_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
metis_tuner.py
"""
import copy
import logging
import random
import statistics
import warnings
from multiprocessing.dummy import Pool as ThreadPool
import numpy as np
from schema import Schema, Optional
from nni import ClassArgsValidator
fro... | 26,207 | 39.073394 | 133 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GMM/CreateModel.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import sys
from operator import itemgetter
import sklearn.mixture as mm
sys.path.insert(1, os.path.join(sys.path[0], '..'))
def create_model(samples_x, samples_y_aggregation, percentage_goodbatch=0.34):
'''
Create the Gaussi... | 1,671 | 36.155556 | 91 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GMM/Selection.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import random
import sys
from .. import lib_acquisition_function
from .. import lib_constraint_summation
sys.path.insert(1, os.path.join(sys.path[0], '..'))
CONSTRAINT_LOWERBOUND = None
CONSTRAINT_UPPERBOUND = None
CONSTRAINT_PARAMS... | 3,050 | 31.457447 | 93 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GMM/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GP/CreateModel.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import sys
import numpy
import sklearn.gaussian_process as gp
sys.path.insert(1, os.path.join(sys.path[0], '..'))
def create_model(samples_x, samples_y_aggregation,
n_restarts_optimizer=250, is_white_kernel=False):
... | 1,297 | 35.055556 | 93 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GP/OutlierDetection.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
OutlierDectection.py
"""
import os
import sys
from multiprocessing.dummy import Pool as ThreadPool
from . import CreateModel as gp_create_model
from . import Prediction as gp_prediction
sys.path.insert(1, os.path.join(sys.path[0], '..'))
... | 3,350 | 37.079545 | 119 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GP/Prediction.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import sys
import numpy
sys.path.insert(1, os.path.join(sys.path[0], '..'))
def predict(parameters_value, regressor_gp):
'''
Predict by Gaussian Process Model
'''
parameters_value = numpy.array(parameters_value).resh... | 451 | 21.6 | 87 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GP/Selection.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import random
import sys
from .. import lib_acquisition_function
from .. import lib_constraint_summation
from .. import lib_data
from . import Prediction as gp_prediction
sys.path.insert(1, os.path.join(sys.path[0], '..'))
CONSTRAINT... | 3,710 | 36.867347 | 100 | py |
nni | nni-master/nni/algorithms/hpo/metis_tuner/Regression_GP/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .networkmorphism_tuner import NetworkMorphismTuner, NetworkMorphismClassArgsValidator
| 165 | 32.2 | 90 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/bayesian.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import random
from copy import deepcopy
from functools import total_ordering
from queue import PriorityQueue
import numpy as np
from scipy.linalg import LinAlgError, cho_solve, cholesky, solve_triangular
from scipy.optimize import li... | 15,925 | 31.973085 | 93 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/graph.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
from collections.abc import Iterable
from copy import deepcopy, copy
from queue import Queue
import numpy as np
import torch
from .layer_transformer import (
add_noise,
wider_bn,
wider_next_conv,
wider_next_dense,
... | 38,162 | 37.316265 | 108 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/graph_transformer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from copy import deepcopy
from random import randrange, sample
from .graph import NetworkDescriptor
from .layers import (
StubDense,
StubReLU,
get_batch_norm_class,
get_conv_class,
get_dropout_class,
get_pooling_class,
... | 5,039 | 29 | 92 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/layer_transformer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
from .layers import (
StubDense,
StubReLU,
get_batch_norm_class,
get_conv_class,
get_n_dim,
)
NOISE_RATIO = 1e-4
def deeper_conv_block(conv_layer, kernel_size, weighted=True):
'''deeper conv layer.
... | 8,711 | 31.875472 | 87 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/layers.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from abc import abstractmethod
from collections.abc import Iterable
import torch
from torch import nn
from torch.nn import functional
from .utils import Constant
class AvgPool(nn.Module):
"""
AvgPool Module.
"""
def __init__(s... | 21,265 | 23.641947 | 112 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/networkmorphism_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
networkmorphsim_tuner.py
"""
import logging
import os
from schema import Optional, Schema
from nni import ClassArgsValidator
from nni.tuner import Tuner
from nni.utils import OptimizeMode, extract_scalar_reward
from .bayesian import Bayesian... | 10,288 | 30.273556 | 93 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/nn.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from abc import abstractmethod
from .graph import Graph
from .layers import (StubDense, StubDropout1d,
StubReLU, get_batch_norm_class,
get_conv_class,
... | 6,734 | 39.329341 | 117 | py |
nni | nni-master/nni/algorithms/hpo/networkmorphism_tuner/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
class Constant:
'''Constant for the Tuner.
'''
MAX_LAYERS = 100
N_NEIGHBOURS = 8
MAX_MODEL_SIZE = 1 << 24
KERNEL_LAMBDA = 1.0
BETA = 2.576
MLP_MODEL_LEN = 3
MLP_MODEL_WIDTH = 5
MODEL_LEN = 3
MODEL_WIDT... | 509 | 20.25 | 38 | py |
nni | nni-master/nni/algorithms/hpo/ppo_tuner/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .ppo_tuner import PPOTuner, PPOClassArgsValidator
| 129 | 25 | 54 | py |
nni | nni-master/nni/algorithms/hpo/ppo_tuner/distri.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
functions for sampling from hidden state
"""
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from .util import fc
class Pd:
"""
A particular probability distribution
"""
def flatparam(self):
raise NotImp... | 6,719 | 35.521739 | 121 | py |
nni | nni-master/nni/algorithms/hpo/ppo_tuner/model.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
the main model of policy/value network
"""
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from .util import initialize, get_session
class Model:
"""
We use this object to :
__init__:
- Creates the st... | 5,513 | 35.039216 | 108 | py |
nni | nni-master/nni/algorithms/hpo/ppo_tuner/policy.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
build policy/value network from model
"""
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from .distri import CategoricalPdType
from .util import lstm_model, fc, observation_placeholder, adjust_shape
class PolicyWithValue:
... | 8,771 | 36.974026 | 140 | py |
nni | nni-master/nni/algorithms/hpo/ppo_tuner/ppo_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
ppo_tuner.py including:
class PPOTuner
"""
import copy
import logging
import numpy as np
from gym import spaces
from schema import Schema, Optional
import nni
from nni import ClassArgsValidator
from nni.tuner import Tuner
from nni.utils... | 26,443 | 39.558282 | 131 | py |
nni | nni-master/nni/algorithms/hpo/ppo_tuner/util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
util functions
"""
import os
import random
import multiprocessing
import numpy as np
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from gym.spaces import Discrete, Box, MultiDiscrete
def set_global_seeds(i):
"""set global s... | 8,816 | 32.781609 | 140 | py |
nni | nni-master/nni/algorithms/hpo/smac_tuner/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .smac_tuner import SMACTuner, SMACClassArgsValidator
| 132 | 25.6 | 57 | py |
nni | nni-master/nni/algorithms/hpo/smac_tuner/convert_ss_to_scenario.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import numpy as np
def get_json_content(file_path):
"""
Load json file content
Parameters
----------
file_path:
path to the file
Raises
------
TypeError
Error with the file path
... | 8,951 | 43.098522 | 120 | py |
nni | nni-master/nni/algorithms/hpo/smac_tuner/smac_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
smac_tuner.py
"""
import logging
import sys
import numpy as np
from schema import Schema, Optional
from smac.facade.epils_facade import EPILS
from smac.facade.roar_facade import ROAR
from smac.facade.smac_facade import SMAC
from smac.scena... | 14,724 | 38.266667 | 131 | py |
nni | nni-master/nni/common/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .serializer import trace, dump, load, is_traceable
| 130 | 25.2 | 55 | py |
nni | nni-master/nni/common/blob_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import hashlib
import os
import shutil
import subprocess
import tempfile
from pathlib import Path
from shutil import which
from typing import Optional
import tqdm
__all__ = ['NNI_BLOB', 'load_or_download_file', 'upload_file', 'nn... | 5,505 | 35.95302 | 117 | py |
nni | nni-master/nni/common/device.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from dataclasses import dataclass
from abc import ABC, abstractmethod
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
@dataclass
class Device(ABC):
node_id: str
status: Literal['idle', ... | 2,091 | 23.904762 | 95 | py |
nni | nni-master/nni/common/framework.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
__all__ = ['set_default_framework', 'get_default_framework', 'shortcut_module', 'shortcut_framework']
import importlib
import os
import sys
from typing import Optional, cast
from typing_extensions import Literal
framework_type = Literal['pytor... | 3,315 | 34.276596 | 130 | py |
nni | nni-master/nni/common/graph_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import queue
import re
from collections import defaultdict
from typing import List, Dict
import torch
from torch.utils.tensorboard._pytorch_graph import NodePy, NodePyIO, NodePyOP, GraphPy
CLASSTYPE_KIND = 'ClassType'
GETATTR_KIND... | 36,291 | 41.546307 | 136 | py |
nni | nni-master/nni/common/nas_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
import logging
from .. import trial
_logger = logging.getLogger(__name__)
_MUTABLE_LAYER_SPACE_PREFIX = "_mutable_layer"
_namespace = {}
_tf_variables = {}
_arch_logits_list = []
_optimizer = None
_train_op = None
def classi... | 13,442 | 41.273585 | 122 | py |
nni | nni-master/nni/common/serializer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import abc
import base64
import collections.abc
import copy
import functools
import inspect
import numbers
import os
import sys
import types
import warnings
from io import IOBase
from typing import Any, Dict, List, Optional, Type, TypeVar, Tuple,... | 40,395 | 41.432773 | 157 | py |
nni | nni-master/nni/common/types.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from nni.common.version import torch_version_is_2
if torch_version_is_2():
from torch.optim.lr_scheduler import LRScheduler # type: ignore
SCHEDULER = LRScheduler
else:
from torch.optim.lr_scheduler import _LRScheduler
SCHEDULER... | 336 | 27.083333 | 68 | py |
nni | nni-master/nni/common/version.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import logging
import sys
import warnings
import cloudpickle
import json_tricks
import numpy
import yaml
import nni
def _minor_version_tuple(version_str: str) -> tuple[int, int]:
# If not a number, retur... | 2,995 | 31.215054 | 109 | py |
nni | nni-master/nni/common/concrete_trace_utils/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
FX is a toolkit for developers to use to transform ``nn.Module`` instances. FX consists of three main components, and this pipeline of
components (symbolic tracing -> intermediate representation -> transforms -> Python code generation) consti... | 789 | 48.375 | 138 | py |
nni | nni-master/nni/common/concrete_trace_utils/concrete_proxy.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import dis
import logging
import inspect
import operator
from typing import List, Optional, Iterable, Any, Set, Union
import torch
from torch.fx._compatibility import compatibility
from torch.fx.graph import ... | 16,359 | 37.767773 | 138 | py |
nni | nni-master/nni/common/concrete_trace_utils/concrete_tracer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import collections
import copy
import sys
import inspect
import logging
import operator
import functools
import builtins
from itertools import chain
from types import BuiltinMethodType, FunctionType, MethodDes... | 78,064 | 45.942273 | 139 | py |
nni | nni-master/nni/common/concrete_trace_utils/counter.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Any, Callable, Dict, List, Tuple, Optional, Union
from dataclasses import dataclass, field
import torch
import torch.fx
from torch.fx import Interpreter
from torch.fx.node import Argument, Node
from .flop_utils import flop_co... | 9,272 | 32.597826 | 115 | py |
nni | nni-master/nni/common/concrete_trace_utils/flop_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# adopted from https://github.com/facebookresearch/fvcore/blob/main/fvcore/nn/jit_handles.py
# ideas from https://pastebin.com/AkvAyJBw
# and https://dev-discuss.pytorch.org/t/the-ideal-pytorch-flop-counter-with-torch-dispatch/505
import operato... | 17,372 | 32.15458 | 131 | py |
nni | nni-master/nni/common/concrete_trace_utils/operator_patcher.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .concrete_tracer import ConcreteTracer
import ast
import builtins
import inspect
import logging
import platform
from textwrap import dedent
from types import MethodType, FunctionType
f... | 11,515 | 38.438356 | 138 | py |
nni | nni-master/nni/common/concrete_trace_utils/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import builtins
import operator
from typing import Any, Callable, Type
import functools
import torch
from torch.fx import Node
# These need to run in global scope to handle nested calls correctly
_orig_module_call: Callable = torch.nn.Module.__... | 4,278 | 37.54955 | 104 | py |
nni | nni-master/nni/common/hpo_utils/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .dedup import Deduplicator
from .validation import validate_search_space
from .formatting import *
from .optimize_mode import OptimizeMode
| 218 | 26.375 | 45 | py |