repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.fit_theta
def fit_theta(self): """use least squares to fit all default curves parameter seperately Returns ------- None """ x = range(1, self.point_num + 1) y = self.trial_history for i in range(NUM_OF_FUNCTIONS): model = curve_combination_model...
python
def fit_theta(self): """use least squares to fit all default curves parameter seperately Returns ------- None """ x = range(1, self.point_num + 1) y = self.trial_history for i in range(NUM_OF_FUNCTIONS): model = curve_combination_model...
[ "def", "fit_theta", "(", "self", ")", ":", "x", "=", "range", "(", "1", ",", "self", ".", "point_num", "+", "1", ")", "y", "=", "self", ".", "trial_history", "for", "i", "in", "range", "(", "NUM_OF_FUNCTIONS", ")", ":", "model", "=", "curve_combinati...
use least squares to fit all default curves parameter seperately Returns ------- None
[ "use", "least", "squares", "to", "fit", "all", "default", "curves", "parameter", "seperately", "Returns", "-------", "None" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L54-L86
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.filter_curve
def filter_curve(self): """filter the poor performing curve Returns ------- None """ avg = np.sum(self.trial_history) / self.point_num standard = avg * avg * self.point_num predict_data = [] tmp_model = [] for i in range(NUM_OF_FUN...
python
def filter_curve(self): """filter the poor performing curve Returns ------- None """ avg = np.sum(self.trial_history) / self.point_num standard = avg * avg * self.point_num predict_data = [] tmp_model = [] for i in range(NUM_OF_FUN...
[ "def", "filter_curve", "(", "self", ")", ":", "avg", "=", "np", ".", "sum", "(", "self", ".", "trial_history", ")", "/", "self", ".", "point_num", "standard", "=", "avg", "*", "avg", "*", "self", ".", "point_num", "predict_data", "=", "[", "]", "tmp_...
filter the poor performing curve Returns ------- None
[ "filter", "the", "poor", "performing", "curve", "Returns", "-------", "None" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L88-L116
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.predict_y
def predict_y(self, model, pos): """return the predict y of 'model' when epoch = pos Parameters ---------- model: string name of the curve function model pos: int the epoch number of the position you want to predict Returns ------...
python
def predict_y(self, model, pos): """return the predict y of 'model' when epoch = pos Parameters ---------- model: string name of the curve function model pos: int the epoch number of the position you want to predict Returns ------...
[ "def", "predict_y", "(", "self", ",", "model", ",", "pos", ")", ":", "if", "model_para_num", "[", "model", "]", "==", "2", ":", "y", "=", "all_models", "[", "model", "]", "(", "pos", ",", "model_para", "[", "model", "]", "[", "0", "]", ",", "mode...
return the predict y of 'model' when epoch = pos Parameters ---------- model: string name of the curve function model pos: int the epoch number of the position you want to predict Returns ------- int: The expected matr...
[ "return", "the", "predict", "y", "of", "model", "when", "epoch", "=", "pos", "Parameters", "----------", "model", ":", "string", "name", "of", "the", "curve", "function", "model", "pos", ":", "int", "the", "epoch", "number", "of", "the", "position", "you",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L118-L139
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.f_comb
def f_comb(self, pos, sample): """return the value of the f_comb when epoch = pos Parameters ---------- pos: int the epoch number of the position you want to predict sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} ...
python
def f_comb(self, pos, sample): """return the value of the f_comb when epoch = pos Parameters ---------- pos: int the epoch number of the position you want to predict sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} ...
[ "def", "f_comb", "(", "self", ",", "pos", ",", "sample", ")", ":", "ret", "=", "0", "for", "i", "in", "range", "(", "self", ".", "effective_model_num", ")", ":", "model", "=", "self", ".", "effective_model", "[", "i", "]", "y", "=", "self", ".", ...
return the value of the f_comb when epoch = pos Parameters ---------- pos: int the epoch number of the position you want to predict sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- int ...
[ "return", "the", "value", "of", "the", "f_comb", "when", "epoch", "=", "pos" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L141-L161
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.normalize_weight
def normalize_weight(self, samples): """normalize weight Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} ...
python
def normalize_weight(self, samples): """normalize weight Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} ...
[ "def", "normalize_weight", "(", "self", ",", "samples", ")", ":", "for", "i", "in", "range", "(", "NUM_OF_INSTANCE", ")", ":", "total", "=", "0", "for", "j", "in", "range", "(", "self", ".", "effective_model_num", ")", ":", "total", "+=", "samples", "[...
normalize weight Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} Returns ------- list ...
[ "normalize", "weight", "Parameters", "----------", "samples", ":", "list", "a", "collection", "of", "sample", "it", "s", "a", "(", "NUM_OF_INSTANCE", "*", "NUM_OF_FUNCTIONS", ")", "matrix", "representing", "{{", "w11", "w12", "...", "w1k", "}", "{", "w21", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L163-L183
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.sigma_sq
def sigma_sq(self, sample): """returns the value of sigma square, given the weight's sample Parameters ---------- sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- float the value...
python
def sigma_sq(self, sample): """returns the value of sigma square, given the weight's sample Parameters ---------- sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- float the value...
[ "def", "sigma_sq", "(", "self", ",", "sample", ")", ":", "ret", "=", "0", "for", "i", "in", "range", "(", "1", ",", "self", ".", "point_num", "+", "1", ")", ":", "temp", "=", "self", ".", "trial_history", "[", "i", "-", "1", "]", "-", "self", ...
returns the value of sigma square, given the weight's sample Parameters ---------- sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- float the value of sigma square, given the weight's sa...
[ "returns", "the", "value", "of", "sigma", "square", "given", "the", "weight", "s", "sample", "Parameters", "----------", "sample", ":", "list", "sample", "is", "a", "(", "1", "*", "NUM_OF_FUNCTIONS", ")", "matrix", "representing", "{", "w1", "w2", "...", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L185-L202
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.normal_distribution
def normal_distribution(self, pos, sample): """returns the value of normal distribution, given the weight's sample and target position Parameters ---------- pos: int the epoch number of the position you want to predict sample: list sample is a (1 ...
python
def normal_distribution(self, pos, sample): """returns the value of normal distribution, given the weight's sample and target position Parameters ---------- pos: int the epoch number of the position you want to predict sample: list sample is a (1 ...
[ "def", "normal_distribution", "(", "self", ",", "pos", ",", "sample", ")", ":", "curr_sigma_sq", "=", "self", ".", "sigma_sq", "(", "sample", ")", "delta", "=", "self", ".", "trial_history", "[", "pos", "-", "1", "]", "-", "self", ".", "f_comb", "(", ...
returns the value of normal distribution, given the weight's sample and target position Parameters ---------- pos: int the epoch number of the position you want to predict sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk...
[ "returns", "the", "value", "of", "normal", "distribution", "given", "the", "weight", "s", "sample", "and", "target", "position", "Parameters", "----------", "pos", ":", "int", "the", "epoch", "number", "of", "the", "position", "you", "want", "to", "predict", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L204-L221
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.likelihood
def likelihood(self, samples): """likelihood Parameters ---------- sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- float likelihood """ ret = np.ones(NUM_OF_INST...
python
def likelihood(self, samples): """likelihood Parameters ---------- sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- float likelihood """ ret = np.ones(NUM_OF_INST...
[ "def", "likelihood", "(", "self", ",", "samples", ")", ":", "ret", "=", "np", ".", "ones", "(", "NUM_OF_INSTANCE", ")", "for", "i", "in", "range", "(", "NUM_OF_INSTANCE", ")", ":", "for", "j", "in", "range", "(", "1", ",", "self", ".", "point_num", ...
likelihood Parameters ---------- sample: list sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} Returns ------- float likelihood
[ "likelihood" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L223-L240
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.prior
def prior(self, samples): """priori distribution Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} Retu...
python
def prior(self, samples): """priori distribution Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} Retu...
[ "def", "prior", "(", "self", ",", "samples", ")", ":", "ret", "=", "np", ".", "ones", "(", "NUM_OF_INSTANCE", ")", "for", "i", "in", "range", "(", "NUM_OF_INSTANCE", ")", ":", "for", "j", "in", "range", "(", "self", ".", "effective_model_num", ")", "...
priori distribution Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} Returns ------- float ...
[ "priori", "distribution", "Parameters", "----------", "samples", ":", "list", "a", "collection", "of", "sample", "it", "s", "a", "(", "NUM_OF_INSTANCE", "*", "NUM_OF_FUNCTIONS", ")", "matrix", "representing", "{{", "w11", "w12", "...", "w1k", "}", "{", "w21", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L242-L263
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.target_distribution
def target_distribution(self, samples): """posterior probability Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}...
python
def target_distribution(self, samples): """posterior probability Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}...
[ "def", "target_distribution", "(", "self", ",", "samples", ")", ":", "curr_likelihood", "=", "self", ".", "likelihood", "(", "samples", ")", "curr_prior", "=", "self", ".", "prior", "(", "samples", ")", "ret", "=", "np", ".", "ones", "(", "NUM_OF_INSTANCE"...
posterior probability Parameters ---------- samples: list a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix, representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}} Returns ------- ...
[ "posterior", "probability", "Parameters", "----------", "samples", ":", "list", "a", "collection", "of", "sample", "it", "s", "a", "(", "NUM_OF_INSTANCE", "*", "NUM_OF_FUNCTIONS", ")", "matrix", "representing", "{{", "w11", "w12", "...", "w1k", "}", "{", "w21"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L265-L284
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.mcmc_sampling
def mcmc_sampling(self): """Adjust the weight of each function using mcmc sampling. The initial value of each weight is evenly distribute. Brief introduction: (1)Definition of sample: Sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} (2)Definitio...
python
def mcmc_sampling(self): """Adjust the weight of each function using mcmc sampling. The initial value of each weight is evenly distribute. Brief introduction: (1)Definition of sample: Sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} (2)Definitio...
[ "def", "mcmc_sampling", "(", "self", ")", ":", "init_weight", "=", "np", ".", "ones", "(", "(", "self", ".", "effective_model_num", ")", ",", "dtype", "=", "np", ".", "float", ")", "/", "self", ".", "effective_model_num", "self", ".", "weight_samples", "...
Adjust the weight of each function using mcmc sampling. The initial value of each weight is evenly distribute. Brief introduction: (1)Definition of sample: Sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk} (2)Definition of samples: Samples is...
[ "Adjust", "the", "weight", "of", "each", "function", "using", "mcmc", "sampling", ".", "The", "initial", "value", "of", "each", "weight", "is", "evenly", "distribute", ".", "Brief", "introduction", ":", "(", "1", ")", "Definition", "of", "sample", ":", "Sa...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L286-L318
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
CurveModel.predict
def predict(self, trial_history): """predict the value of target position Parameters ---------- trial_history: list The history performance matrix of each trial. Returns ------- float expected final result performance of this hype...
python
def predict(self, trial_history): """predict the value of target position Parameters ---------- trial_history: list The history performance matrix of each trial. Returns ------- float expected final result performance of this hype...
[ "def", "predict", "(", "self", ",", "trial_history", ")", ":", "self", ".", "trial_history", "=", "trial_history", "self", ".", "point_num", "=", "len", "(", "trial_history", ")", "self", ".", "fit_theta", "(", ")", "self", ".", "filter_curve", "(", ")", ...
predict the value of target position Parameters ---------- trial_history: list The history performance matrix of each trial. Returns ------- float expected final result performance of this hyperparameter config
[ "predict", "the", "value", "of", "target", "position", "Parameters", "----------", "trial_history", ":", "list", "The", "history", "performance", "matrix", "of", "each", "trial", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/model_factory.py#L320-L344
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/OutlierDetection.py
_outlierDetection_threaded
def _outlierDetection_threaded(inputs): ''' Detect the outlier ''' [samples_idx, samples_x, samples_y_aggregation] = inputs sys.stderr.write("[%s] DEBUG: Evaluating %dth of %d samples\n"\ % (os.path.basename(__file__), samples_idx + 1, len(samples_x))) outlier = None ...
python
def _outlierDetection_threaded(inputs): ''' Detect the outlier ''' [samples_idx, samples_x, samples_y_aggregation] = inputs sys.stderr.write("[%s] DEBUG: Evaluating %dth of %d samples\n"\ % (os.path.basename(__file__), samples_idx + 1, len(samples_x))) outlier = None ...
[ "def", "_outlierDetection_threaded", "(", "inputs", ")", ":", "[", "samples_idx", ",", "samples_x", ",", "samples_y_aggregation", "]", "=", "inputs", "sys", ".", "stderr", ".", "write", "(", "\"[%s] DEBUG: Evaluating %dth of %d samples\\n\"", "%", "(", "os", ".", ...
Detect the outlier
[ "Detect", "the", "outlier" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/OutlierDetection.py#L32-L53
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/OutlierDetection.py
outlierDetection_threaded
def outlierDetection_threaded(samples_x, samples_y_aggregation): ''' Use Multi-thread to detect the outlier ''' outliers = [] threads_inputs = [[samples_idx, samples_x, samples_y_aggregation]\ for samples_idx in range(0, len(samples_x))] threads_pool = ThreadPool(min...
python
def outlierDetection_threaded(samples_x, samples_y_aggregation): ''' Use Multi-thread to detect the outlier ''' outliers = [] threads_inputs = [[samples_idx, samples_x, samples_y_aggregation]\ for samples_idx in range(0, len(samples_x))] threads_pool = ThreadPool(min...
[ "def", "outlierDetection_threaded", "(", "samples_x", ",", "samples_y_aggregation", ")", ":", "outliers", "=", "[", "]", "threads_inputs", "=", "[", "[", "samples_idx", ",", "samples_x", ",", "samples_y_aggregation", "]", "for", "samples_idx", "in", "range", "(", ...
Use Multi-thread to detect the outlier
[ "Use", "Multi", "-", "thread", "to", "detect", "the", "outlier" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/OutlierDetection.py#L55-L75
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
deeper_conv_block
def deeper_conv_block(conv_layer, kernel_size, weighted=True): '''deeper conv layer. ''' n_dim = get_n_dim(conv_layer) filter_shape = (kernel_size,) * 2 n_filters = conv_layer.filters weight = np.zeros((n_filters, n_filters) + filter_shape) center = tuple(map(lambda x: int((x - 1) / 2), filt...
python
def deeper_conv_block(conv_layer, kernel_size, weighted=True): '''deeper conv layer. ''' n_dim = get_n_dim(conv_layer) filter_shape = (kernel_size,) * 2 n_filters = conv_layer.filters weight = np.zeros((n_filters, n_filters) + filter_shape) center = tuple(map(lambda x: int((x - 1) / 2), filt...
[ "def", "deeper_conv_block", "(", "conv_layer", ",", "kernel_size", ",", "weighted", "=", "True", ")", ":", "n_dim", "=", "get_n_dim", "(", "conv_layer", ")", "filter_shape", "=", "(", "kernel_size", ",", ")", "*", "2", "n_filters", "=", "conv_layer", ".", ...
deeper conv layer.
[ "deeper", "conv", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L34-L65
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
dense_to_deeper_block
def dense_to_deeper_block(dense_layer, weighted=True): '''deeper dense layer. ''' units = dense_layer.units weight = np.eye(units) bias = np.zeros(units) new_dense_layer = StubDense(units, units) if weighted: new_dense_layer.set_weights( (add_noise(weight, np.array([0, 1]...
python
def dense_to_deeper_block(dense_layer, weighted=True): '''deeper dense layer. ''' units = dense_layer.units weight = np.eye(units) bias = np.zeros(units) new_dense_layer = StubDense(units, units) if weighted: new_dense_layer.set_weights( (add_noise(weight, np.array([0, 1]...
[ "def", "dense_to_deeper_block", "(", "dense_layer", ",", "weighted", "=", "True", ")", ":", "units", "=", "dense_layer", ".", "units", "weight", "=", "np", ".", "eye", "(", "units", ")", "bias", "=", "np", ".", "zeros", "(", "units", ")", "new_dense_laye...
deeper dense layer.
[ "deeper", "dense", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L68-L79
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
wider_pre_dense
def wider_pre_dense(layer, n_add, weighted=True): '''wider previous dense layer. ''' if not weighted: return StubDense(layer.input_units, layer.units + n_add) n_units2 = layer.units teacher_w, teacher_b = layer.get_weights() rand = np.random.randint(n_units2, size=n_add) student_w ...
python
def wider_pre_dense(layer, n_add, weighted=True): '''wider previous dense layer. ''' if not weighted: return StubDense(layer.input_units, layer.units + n_add) n_units2 = layer.units teacher_w, teacher_b = layer.get_weights() rand = np.random.randint(n_units2, size=n_add) student_w ...
[ "def", "wider_pre_dense", "(", "layer", ",", "n_add", ",", "weighted", "=", "True", ")", ":", "if", "not", "weighted", ":", "return", "StubDense", "(", "layer", ".", "input_units", ",", "layer", ".", "units", "+", "n_add", ")", "n_units2", "=", "layer", ...
wider previous dense layer.
[ "wider", "previous", "dense", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L82-L106
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
wider_pre_conv
def wider_pre_conv(layer, n_add_filters, weighted=True): '''wider previous conv layer. ''' n_dim = get_n_dim(layer) if not weighted: return get_conv_class(n_dim)( layer.input_channel, layer.filters + n_add_filters, kernel_size=layer.kernel_size, ) ...
python
def wider_pre_conv(layer, n_add_filters, weighted=True): '''wider previous conv layer. ''' n_dim = get_n_dim(layer) if not weighted: return get_conv_class(n_dim)( layer.input_channel, layer.filters + n_add_filters, kernel_size=layer.kernel_size, ) ...
[ "def", "wider_pre_conv", "(", "layer", ",", "n_add_filters", ",", "weighted", "=", "True", ")", ":", "n_dim", "=", "get_n_dim", "(", "layer", ")", "if", "not", "weighted", ":", "return", "get_conv_class", "(", "n_dim", ")", "(", "layer", ".", "input_channe...
wider previous conv layer.
[ "wider", "previous", "conv", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L109-L139
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
wider_next_conv
def wider_next_conv(layer, start_dim, total_dim, n_add, weighted=True): '''wider next conv layer. ''' n_dim = get_n_dim(layer) if not weighted: return get_conv_class(n_dim)(layer.input_channel + n_add, layer.filters, kerne...
python
def wider_next_conv(layer, start_dim, total_dim, n_add, weighted=True): '''wider next conv layer. ''' n_dim = get_n_dim(layer) if not weighted: return get_conv_class(n_dim)(layer.input_channel + n_add, layer.filters, kerne...
[ "def", "wider_next_conv", "(", "layer", ",", "start_dim", ",", "total_dim", ",", "n_add", ",", "weighted", "=", "True", ")", ":", "n_dim", "=", "get_n_dim", "(", "layer", ")", "if", "not", "weighted", ":", "return", "get_conv_class", "(", "n_dim", ")", "...
wider next conv layer.
[ "wider", "next", "conv", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L142-L166
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
wider_bn
def wider_bn(layer, start_dim, total_dim, n_add, weighted=True): '''wider batch norm layer. ''' n_dim = get_n_dim(layer) if not weighted: return get_batch_norm_class(n_dim)(layer.num_features + n_add) weights = layer.get_weights() new_weights = [ add_noise(np.ones(n_add, dtype=...
python
def wider_bn(layer, start_dim, total_dim, n_add, weighted=True): '''wider batch norm layer. ''' n_dim = get_n_dim(layer) if not weighted: return get_batch_norm_class(n_dim)(layer.num_features + n_add) weights = layer.get_weights() new_weights = [ add_noise(np.ones(n_add, dtype=...
[ "def", "wider_bn", "(", "layer", ",", "start_dim", ",", "total_dim", ",", "n_add", ",", "weighted", "=", "True", ")", ":", "n_dim", "=", "get_n_dim", "(", "layer", ")", "if", "not", "weighted", ":", "return", "get_batch_norm_class", "(", "n_dim", ")", "(...
wider batch norm layer.
[ "wider", "batch", "norm", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L169-L194
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
wider_next_dense
def wider_next_dense(layer, start_dim, total_dim, n_add, weighted=True): '''wider next dense layer. ''' if not weighted: return StubDense(layer.input_units + n_add, layer.units) teacher_w, teacher_b = layer.get_weights() student_w = teacher_w.copy() n_units_each_channel = int(teacher_w.s...
python
def wider_next_dense(layer, start_dim, total_dim, n_add, weighted=True): '''wider next dense layer. ''' if not weighted: return StubDense(layer.input_units + n_add, layer.units) teacher_w, teacher_b = layer.get_weights() student_w = teacher_w.copy() n_units_each_channel = int(teacher_w.s...
[ "def", "wider_next_dense", "(", "layer", ",", "start_dim", ",", "total_dim", ",", "n_add", ",", "weighted", "=", "True", ")", ":", "if", "not", "weighted", ":", "return", "StubDense", "(", "layer", ".", "input_units", "+", "n_add", ",", "layer", ".", "un...
wider next dense layer.
[ "wider", "next", "dense", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L197-L220
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
add_noise
def add_noise(weights, other_weights): '''add noise to the layer. ''' w_range = np.ptp(other_weights.flatten()) noise_range = NOISE_RATIO * w_range noise = np.random.uniform(-noise_range / 2.0, noise_range / 2.0, weights.shape) return np.add(noise, weights)
python
def add_noise(weights, other_weights): '''add noise to the layer. ''' w_range = np.ptp(other_weights.flatten()) noise_range = NOISE_RATIO * w_range noise = np.random.uniform(-noise_range / 2.0, noise_range / 2.0, weights.shape) return np.add(noise, weights)
[ "def", "add_noise", "(", "weights", ",", "other_weights", ")", ":", "w_range", "=", "np", ".", "ptp", "(", "other_weights", ".", "flatten", "(", ")", ")", "noise_range", "=", "NOISE_RATIO", "*", "w_range", "noise", "=", "np", ".", "random", ".", "uniform...
add noise to the layer.
[ "add", "noise", "to", "the", "layer", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L223-L229
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
init_dense_weight
def init_dense_weight(layer): '''initilize dense layer weight. ''' units = layer.units weight = np.eye(units) bias = np.zeros(units) layer.set_weights( (add_noise(weight, np.array([0, 1])), add_noise(bias, np.array([0, 1]))) )
python
def init_dense_weight(layer): '''initilize dense layer weight. ''' units = layer.units weight = np.eye(units) bias = np.zeros(units) layer.set_weights( (add_noise(weight, np.array([0, 1])), add_noise(bias, np.array([0, 1]))) )
[ "def", "init_dense_weight", "(", "layer", ")", ":", "units", "=", "layer", ".", "units", "weight", "=", "np", ".", "eye", "(", "units", ")", "bias", "=", "np", ".", "zeros", "(", "units", ")", "layer", ".", "set_weights", "(", "(", "add_noise", "(", ...
initilize dense layer weight.
[ "initilize", "dense", "layer", "weight", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L232-L240
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
init_conv_weight
def init_conv_weight(layer): '''initilize conv layer weight. ''' n_filters = layer.filters filter_shape = (layer.kernel_size,) * get_n_dim(layer) weight = np.zeros((n_filters, n_filters) + filter_shape) center = tuple(map(lambda x: int((x - 1) / 2), filter_shape)) for i in range(n_filters):...
python
def init_conv_weight(layer): '''initilize conv layer weight. ''' n_filters = layer.filters filter_shape = (layer.kernel_size,) * get_n_dim(layer) weight = np.zeros((n_filters, n_filters) + filter_shape) center = tuple(map(lambda x: int((x - 1) / 2), filter_shape)) for i in range(n_filters):...
[ "def", "init_conv_weight", "(", "layer", ")", ":", "n_filters", "=", "layer", ".", "filters", "filter_shape", "=", "(", "layer", ".", "kernel_size", ",", ")", "*", "get_n_dim", "(", "layer", ")", "weight", "=", "np", ".", "zeros", "(", "(", "n_filters", ...
initilize conv layer weight.
[ "initilize", "conv", "layer", "weight", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L243-L260
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
init_bn_weight
def init_bn_weight(layer): '''initilize batch norm layer weight. ''' n_filters = layer.num_features new_weights = [ add_noise(np.ones(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters,...
python
def init_bn_weight(layer): '''initilize batch norm layer weight. ''' n_filters = layer.num_features new_weights = [ add_noise(np.ones(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters,...
[ "def", "init_bn_weight", "(", "layer", ")", ":", "n_filters", "=", "layer", ".", "num_features", "new_weights", "=", "[", "add_noise", "(", "np", ".", "ones", "(", "n_filters", ",", "dtype", "=", "np", ".", "float32", ")", ",", "np", ".", "array", "(",...
initilize batch norm layer weight.
[ "initilize", "batch", "norm", "layer", "weight", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L263-L273
train
Microsoft/nni
tools/nni_cmd/tensorboard_utils.py
parse_log_path
def parse_log_path(args, trial_content): '''parse log path''' path_list = [] host_list = [] for trial in trial_content: if args.trial_id and args.trial_id != 'all' and trial.get('id') != args.trial_id: continue pattern = r'(?P<head>.+)://(?P<host>.+):(?P<path>.*)' mat...
python
def parse_log_path(args, trial_content): '''parse log path''' path_list = [] host_list = [] for trial in trial_content: if args.trial_id and args.trial_id != 'all' and trial.get('id') != args.trial_id: continue pattern = r'(?P<head>.+)://(?P<host>.+):(?P<path>.*)' mat...
[ "def", "parse_log_path", "(", "args", ",", "trial_content", ")", ":", "path_list", "=", "[", "]", "host_list", "=", "[", "]", "for", "trial", "in", "trial_content", ":", "if", "args", ".", "trial_id", "and", "args", ".", "trial_id", "!=", "'all'", "and",...
parse log path
[ "parse", "log", "path" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L38-L53
train
Microsoft/nni
tools/nni_cmd/tensorboard_utils.py
copy_data_from_remote
def copy_data_from_remote(args, nni_config, trial_content, path_list, host_list, temp_nni_path): '''use ssh client to copy data from remote machine to local machien''' machine_list = nni_config.get_config('experimentConfig').get('machineList') machine_dict = {} local_path_list = [] for machine in ma...
python
def copy_data_from_remote(args, nni_config, trial_content, path_list, host_list, temp_nni_path): '''use ssh client to copy data from remote machine to local machien''' machine_list = nni_config.get_config('experimentConfig').get('machineList') machine_dict = {} local_path_list = [] for machine in ma...
[ "def", "copy_data_from_remote", "(", "args", ",", "nni_config", ",", "trial_content", ",", "path_list", ",", "host_list", ",", "temp_nni_path", ")", ":", "machine_list", "=", "nni_config", ".", "get_config", "(", "'experimentConfig'", ")", ".", "get", "(", "'mac...
use ssh client to copy data from remote machine to local machien
[ "use", "ssh", "client", "to", "copy", "data", "from", "remote", "machine", "to", "local", "machien" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L55-L69
train
Microsoft/nni
tools/nni_cmd/tensorboard_utils.py
get_path_list
def get_path_list(args, nni_config, trial_content, temp_nni_path): '''get path list according to different platform''' path_list, host_list = parse_log_path(args, trial_content) platform = nni_config.get_config('experimentConfig').get('trainingServicePlatform') if platform == 'local': print_norm...
python
def get_path_list(args, nni_config, trial_content, temp_nni_path): '''get path list according to different platform''' path_list, host_list = parse_log_path(args, trial_content) platform = nni_config.get_config('experimentConfig').get('trainingServicePlatform') if platform == 'local': print_norm...
[ "def", "get_path_list", "(", "args", ",", "nni_config", ",", "trial_content", ",", "temp_nni_path", ")", ":", "path_list", ",", "host_list", "=", "parse_log_path", "(", "args", ",", "trial_content", ")", "platform", "=", "nni_config", ".", "get_config", "(", "...
get path list according to different platform
[ "get", "path", "list", "according", "to", "different", "platform" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L71-L84
train
Microsoft/nni
tools/nni_cmd/tensorboard_utils.py
start_tensorboard_process
def start_tensorboard_process(args, nni_config, path_list, temp_nni_path): '''call cmds to start tensorboard process in local machine''' if detect_port(args.port): print_error('Port %s is used by another process, please reset port!' % str(args.port)) exit(1) stdout_file = open(os.path.j...
python
def start_tensorboard_process(args, nni_config, path_list, temp_nni_path): '''call cmds to start tensorboard process in local machine''' if detect_port(args.port): print_error('Port %s is used by another process, please reset port!' % str(args.port)) exit(1) stdout_file = open(os.path.j...
[ "def", "start_tensorboard_process", "(", "args", ",", "nni_config", ",", "path_list", ",", "temp_nni_path", ")", ":", "if", "detect_port", "(", "args", ".", "port", ")", ":", "print_error", "(", "'Port %s is used by another process, please reset port!'", "%", "str", ...
call cmds to start tensorboard process in local machine
[ "call", "cmds", "to", "start", "tensorboard", "process", "in", "local", "machine" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L92-L109
train
Microsoft/nni
tools/nni_cmd/tensorboard_utils.py
stop_tensorboard
def stop_tensorboard(args): '''stop tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) tensorb...
python
def stop_tensorboard(args): '''stop tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) tensorb...
[ "def", "stop_tensorboard", "(", "args", ")", ":", "experiment_id", "=", "check_experiment_id", "(", "args", ")", "experiment_config", "=", "Experiments", "(", ")", "experiment_dict", "=", "experiment_config", ".", "get_all_experiments", "(", ")", "config_file_name", ...
stop tensorboard
[ "stop", "tensorboard" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L111-L129
train
Microsoft/nni
tools/nni_cmd/tensorboard_utils.py
start_tensorboard
def start_tensorboard(args): '''start tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) rest_...
python
def start_tensorboard(args): '''start tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) rest_...
[ "def", "start_tensorboard", "(", "args", ")", ":", "experiment_id", "=", "check_experiment_id", "(", "args", ")", "experiment_config", "=", "Experiments", "(", ")", "experiment_dict", "=", "experiment_config", ".", "get_all_experiments", "(", ")", "config_file_name", ...
start tensorboard
[ "start", "tensorboard" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L132-L165
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
_ratio_scores
def _ratio_scores(parameters_value, clusteringmodel_gmm_good, clusteringmodel_gmm_bad): ''' The ratio is smaller the better ''' ratio = clusteringmodel_gmm_good.score([parameters_value]) / clusteringmodel_gmm_bad.score([parameters_value]) sigma = 0 return ratio, sigma
python
def _ratio_scores(parameters_value, clusteringmodel_gmm_good, clusteringmodel_gmm_bad): ''' The ratio is smaller the better ''' ratio = clusteringmodel_gmm_good.score([parameters_value]) / clusteringmodel_gmm_bad.score([parameters_value]) sigma = 0 return ratio, sigma
[ "def", "_ratio_scores", "(", "parameters_value", ",", "clusteringmodel_gmm_good", ",", "clusteringmodel_gmm_bad", ")", ":", "ratio", "=", "clusteringmodel_gmm_good", ".", "score", "(", "[", "parameters_value", "]", ")", "/", "clusteringmodel_gmm_bad", ".", "score", "(...
The ratio is smaller the better
[ "The", "ratio", "is", "smaller", "the", "better" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L37-L43
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
selection_r
def selection_r(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, num_starting_points=100, minimize_constraints_fun=None): ''' Call selection ''' minimize_starting_points = [lib_data.rand(x_bounds, x_type...
python
def selection_r(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, num_starting_points=100, minimize_constraints_fun=None): ''' Call selection ''' minimize_starting_points = [lib_data.rand(x_bounds, x_type...
[ "def", "selection_r", "(", "x_bounds", ",", "x_types", ",", "clusteringmodel_gmm_good", ",", "clusteringmodel_gmm_bad", ",", "num_starting_points", "=", "100", ",", "minimize_constraints_fun", "=", "None", ")", ":", "minimize_starting_points", "=", "[", "lib_data", "....
Call selection
[ "Call", "selection" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L45-L61
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
selection
def selection(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, minimize_starting_points, minimize_constraints_fun=None): ''' Select the lowest mu value ''' results = lib_acquisition_function.next_hyperparameter_lo...
python
def selection(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, minimize_starting_points, minimize_constraints_fun=None): ''' Select the lowest mu value ''' results = lib_acquisition_function.next_hyperparameter_lo...
[ "def", "selection", "(", "x_bounds", ",", "x_types", ",", "clusteringmodel_gmm_good", ",", "clusteringmodel_gmm_bad", ",", "minimize_starting_points", ",", "minimize_constraints_fun", "=", "None", ")", ":", "results", "=", "lib_acquisition_function", ".", "next_hyperparam...
Select the lowest mu value
[ "Select", "the", "lowest", "mu", "value" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L63-L77
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
_minimize_constraints_fun_summation
def _minimize_constraints_fun_summation(x): ''' Minimize constraints fun summation ''' summation = sum([x[i] for i in CONSTRAINT_PARAMS_IDX]) return CONSTRAINT_UPPERBOUND >= summation >= CONSTRAINT_LOWERBOUND
python
def _minimize_constraints_fun_summation(x): ''' Minimize constraints fun summation ''' summation = sum([x[i] for i in CONSTRAINT_PARAMS_IDX]) return CONSTRAINT_UPPERBOUND >= summation >= CONSTRAINT_LOWERBOUND
[ "def", "_minimize_constraints_fun_summation", "(", "x", ")", ":", "summation", "=", "sum", "(", "[", "x", "[", "i", "]", "for", "i", "in", "CONSTRAINT_PARAMS_IDX", "]", ")", "return", "CONSTRAINT_UPPERBOUND", ">=", "summation", ">=", "CONSTRAINT_LOWERBOUND" ]
Minimize constraints fun summation
[ "Minimize", "constraints", "fun", "summation" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L99-L104
train
Microsoft/nni
examples/trials/sklearn/classification/main.py
load_data
def load_data(): '''Load dataset, use 20newsgroups dataset''' digits = load_digits() X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, random_state=99, test_size=0.25) ss = StandardScaler() X_train = ss.fit_transform(X_train) X_test = ss.transform(X_test) retu...
python
def load_data(): '''Load dataset, use 20newsgroups dataset''' digits = load_digits() X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, random_state=99, test_size=0.25) ss = StandardScaler() X_train = ss.fit_transform(X_train) X_test = ss.transform(X_test) retu...
[ "def", "load_data", "(", ")", ":", "digits", "=", "load_digits", "(", ")", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "digits", ".", "data", ",", "digits", ".", "target", ",", "random_state", "=", "99", ",", ...
Load dataset, use 20newsgroups dataset
[ "Load", "dataset", "use", "20newsgroups", "dataset" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/sklearn/classification/main.py#L29-L38
train
Microsoft/nni
examples/trials/sklearn/classification/main.py
get_model
def get_model(PARAMS): '''Get model according to parameters''' model = SVC() model.C = PARAMS.get('C') model.keral = PARAMS.get('keral') model.degree = PARAMS.get('degree') model.gamma = PARAMS.get('gamma') model.coef0 = PARAMS.get('coef0') return model
python
def get_model(PARAMS): '''Get model according to parameters''' model = SVC() model.C = PARAMS.get('C') model.keral = PARAMS.get('keral') model.degree = PARAMS.get('degree') model.gamma = PARAMS.get('gamma') model.coef0 = PARAMS.get('coef0') return model
[ "def", "get_model", "(", "PARAMS", ")", ":", "model", "=", "SVC", "(", ")", "model", ".", "C", "=", "PARAMS", ".", "get", "(", "'C'", ")", "model", ".", "keral", "=", "PARAMS", ".", "get", "(", "'keral'", ")", "model", ".", "degree", "=", "PARAMS...
Get model according to parameters
[ "Get", "model", "according", "to", "parameters" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/sklearn/classification/main.py#L51-L60
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
Bracket.get_hyperparameter_configurations
def get_hyperparameter_configurations(self, num, r, config_generator): """generate num hyperparameter configurations from search space using Bayesian optimization Parameters ---------- num: int the number of hyperparameter configurations Returns ------- ...
python
def get_hyperparameter_configurations(self, num, r, config_generator): """generate num hyperparameter configurations from search space using Bayesian optimization Parameters ---------- num: int the number of hyperparameter configurations Returns ------- ...
[ "def", "get_hyperparameter_configurations", "(", "self", ",", "num", ",", "r", ",", "config_generator", ")", ":", "global", "_KEY", "assert", "self", ".", "i", "==", "0", "hyperparameter_configs", "=", "dict", "(", ")", "for", "_", "in", "range", "(", "num...
generate num hyperparameter configurations from search space using Bayesian optimization Parameters ---------- num: int the number of hyperparameter configurations Returns ------- list a list of hyperparameter configurations. Format: [[key1, valu...
[ "generate", "num", "hyperparameter", "configurations", "from", "search", "space", "using", "Bayesian", "optimization" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L215-L237
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.handle_initialize
def handle_initialize(self, data): """Initialize Tuner, including creating Bayesian optimization-based parametric models and search space formations Parameters ---------- data: search space search space of this experiment Raises ------ Value...
python
def handle_initialize(self, data): """Initialize Tuner, including creating Bayesian optimization-based parametric models and search space formations Parameters ---------- data: search space search space of this experiment Raises ------ Value...
[ "def", "handle_initialize", "(", "self", ",", "data", ")", ":", "logger", ".", "info", "(", "'start to handle_initialize'", ")", "# convert search space jason to ConfigSpace", "self", ".", "handle_update_search_space", "(", "data", ")", "# generate BOHB config_generator usi...
Initialize Tuner, including creating Bayesian optimization-based parametric models and search space formations Parameters ---------- data: search space search space of this experiment Raises ------ ValueError Error: Search space is None
[ "Initialize", "Tuner", "including", "creating", "Bayesian", "optimization", "-", "based", "parametric", "models", "and", "search", "space", "formations" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L344-L375
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.generate_new_bracket
def generate_new_bracket(self): """generate a new bracket""" logger.debug( 'start to create a new SuccessiveHalving iteration, self.curr_s=%d', self.curr_s) if self.curr_s < 0: logger.info("s < 0, Finish this round of Hyperband in BOHB. Generate new round") se...
python
def generate_new_bracket(self): """generate a new bracket""" logger.debug( 'start to create a new SuccessiveHalving iteration, self.curr_s=%d', self.curr_s) if self.curr_s < 0: logger.info("s < 0, Finish this round of Hyperband in BOHB. Generate new round") se...
[ "def", "generate_new_bracket", "(", "self", ")", ":", "logger", ".", "debug", "(", "'start to create a new SuccessiveHalving iteration, self.curr_s=%d'", ",", "self", ".", "curr_s", ")", "if", "self", ".", "curr_s", "<", "0", ":", "logger", ".", "info", "(", "\"...
generate a new bracket
[ "generate", "a", "new", "bracket" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L377-L392
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.handle_request_trial_jobs
def handle_request_trial_jobs(self, data): """recerive the number of request and generate trials Parameters ---------- data: int number of trial jobs that nni manager ask to generate """ # Receive new request self.credit += data for _ in rang...
python
def handle_request_trial_jobs(self, data): """recerive the number of request and generate trials Parameters ---------- data: int number of trial jobs that nni manager ask to generate """ # Receive new request self.credit += data for _ in rang...
[ "def", "handle_request_trial_jobs", "(", "self", ",", "data", ")", ":", "# Receive new request", "self", ".", "credit", "+=", "data", "for", "_", "in", "range", "(", "self", ".", "credit", ")", ":", "self", ".", "_request_one_trial_job", "(", ")" ]
recerive the number of request and generate trials Parameters ---------- data: int number of trial jobs that nni manager ask to generate
[ "recerive", "the", "number", "of", "request", "and", "generate", "trials" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L394-L406
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB._request_one_trial_job
def _request_one_trial_job(self): """get one trial job, i.e., one hyperparameter configuration. If this function is called, Command will be sent by BOHB: a. If there is a parameter need to run, will return "NewTrialJob" with a dict: { 'parameter_id': id of new hyperparamete...
python
def _request_one_trial_job(self): """get one trial job, i.e., one hyperparameter configuration. If this function is called, Command will be sent by BOHB: a. If there is a parameter need to run, will return "NewTrialJob" with a dict: { 'parameter_id': id of new hyperparamete...
[ "def", "_request_one_trial_job", "(", "self", ")", ":", "if", "not", "self", ".", "generated_hyper_configs", ":", "ret", "=", "{", "'parameter_id'", ":", "'-1_0_0'", ",", "'parameter_source'", ":", "'algorithm'", ",", "'parameters'", ":", "''", "}", "send", "(...
get one trial job, i.e., one hyperparameter configuration. If this function is called, Command will be sent by BOHB: a. If there is a parameter need to run, will return "NewTrialJob" with a dict: { 'parameter_id': id of new hyperparameter 'parameter_source': 'algorithm'...
[ "get", "one", "trial", "job", "i", ".", "e", ".", "one", "hyperparameter", "configuration", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L408-L442
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.handle_update_search_space
def handle_update_search_space(self, data): """change json format to ConfigSpace format dict<dict> -> configspace Parameters ---------- data: JSON object search space of this experiment """ search_space = data cs = CS.ConfigurationSpace() for ...
python
def handle_update_search_space(self, data): """change json format to ConfigSpace format dict<dict> -> configspace Parameters ---------- data: JSON object search space of this experiment """ search_space = data cs = CS.ConfigurationSpace() for ...
[ "def", "handle_update_search_space", "(", "self", ",", "data", ")", ":", "search_space", "=", "data", "cs", "=", "CS", ".", "ConfigurationSpace", "(", ")", "for", "var", "in", "search_space", ":", "_type", "=", "str", "(", "search_space", "[", "var", "]", ...
change json format to ConfigSpace format dict<dict> -> configspace Parameters ---------- data: JSON object search space of this experiment
[ "change", "json", "format", "to", "ConfigSpace", "format", "dict<dict", ">", "-", ">", "configspace" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L444-L496
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.handle_trial_end
def handle_trial_end(self, data): """receive the information of trial end and generate next configuaration. Parameters ---------- data: dict() it has three keys: trial_job_id, event, hyper_params trial_job_id: the id generated by training service even...
python
def handle_trial_end(self, data): """receive the information of trial end and generate next configuaration. Parameters ---------- data: dict() it has three keys: trial_job_id, event, hyper_params trial_job_id: the id generated by training service even...
[ "def", "handle_trial_end", "(", "self", ",", "data", ")", ":", "logger", ".", "debug", "(", "'Tuner handle trial end, result is %s'", ",", "data", ")", "hyper_params", "=", "json_tricks", ".", "loads", "(", "data", "[", "'hyper_params'", "]", ")", "s", ",", ...
receive the information of trial end and generate next configuaration. Parameters ---------- data: dict() it has three keys: trial_job_id, event, hyper_params trial_job_id: the id generated by training service event: the job's state hyper_params: ...
[ "receive", "the", "information", "of", "trial", "end", "and", "generate", "next", "configuaration", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L498-L526
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.handle_report_metric_data
def handle_report_metric_data(self, data): """reveice the metric data and update Bayesian optimization with final result Parameters ---------- data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. Raises ------ ...
python
def handle_report_metric_data(self, data): """reveice the metric data and update Bayesian optimization with final result Parameters ---------- data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. Raises ------ ...
[ "def", "handle_report_metric_data", "(", "self", ",", "data", ")", ":", "logger", ".", "debug", "(", "'handle report metric data = %s'", ",", "data", ")", "assert", "'value'", "in", "data", "value", "=", "extract_scalar_reward", "(", "data", "[", "'value'", "]",...
reveice the metric data and update Bayesian optimization with final result Parameters ---------- data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. Raises ------ ValueError Data type not supported
[ "reveice", "the", "metric", "data", "and", "update", "Bayesian", "optimization", "with", "final", "result" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L528-L572
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
BOHB.handle_import_data
def handle_import_data(self, data): """Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value' Raises ------ AssertionError data doesn't have requir...
python
def handle_import_data(self, data): """Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value' Raises ------ AssertionError data doesn't have requir...
[ "def", "handle_import_data", "(", "self", ",", "data", ")", ":", "_completed_num", "=", "0", "for", "trial_info", "in", "data", ":", "logger", ".", "info", "(", "\"Importing data, current processing progress %s / %s\"", "%", "(", "_completed_num", ",", "len", "(",...
Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value' Raises ------ AssertionError data doesn't have required key 'parameter' and 'value'
[ "Import", "additional", "data", "for", "tuning" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L577-L617
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/utils.py
data_transforms_cifar10
def data_transforms_cifar10(args): """ data_transforms for cifar10 dataset """ cifar_mean = [0.49139968, 0.48215827, 0.44653124] cifar_std = [0.24703233, 0.24348505, 0.26158768] train_transform = transforms.Compose( [ transforms.RandomCrop(32, padding=4), transforms...
python
def data_transforms_cifar10(args): """ data_transforms for cifar10 dataset """ cifar_mean = [0.49139968, 0.48215827, 0.44653124] cifar_std = [0.24703233, 0.24348505, 0.26158768] train_transform = transforms.Compose( [ transforms.RandomCrop(32, padding=4), transforms...
[ "def", "data_transforms_cifar10", "(", "args", ")", ":", "cifar_mean", "=", "[", "0.49139968", ",", "0.48215827", ",", "0.44653124", "]", "cifar_std", "=", "[", "0.24703233", ",", "0.24348505", ",", "0.26158768", "]", "train_transform", "=", "transforms", ".", ...
data_transforms for cifar10 dataset
[ "data_transforms", "for", "cifar10", "dataset" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L116-L137
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/utils.py
data_transforms_mnist
def data_transforms_mnist(args, mnist_mean=None, mnist_std=None): """ data_transforms for mnist dataset """ if mnist_mean is None: mnist_mean = [0.5] if mnist_std is None: mnist_std = [0.5] train_transform = transforms.Compose( [ transforms.RandomCrop(28, paddin...
python
def data_transforms_mnist(args, mnist_mean=None, mnist_std=None): """ data_transforms for mnist dataset """ if mnist_mean is None: mnist_mean = [0.5] if mnist_std is None: mnist_std = [0.5] train_transform = transforms.Compose( [ transforms.RandomCrop(28, paddin...
[ "def", "data_transforms_mnist", "(", "args", ",", "mnist_mean", "=", "None", ",", "mnist_std", "=", "None", ")", ":", "if", "mnist_mean", "is", "None", ":", "mnist_mean", "=", "[", "0.5", "]", "if", "mnist_std", "is", "None", ":", "mnist_std", "=", "[", ...
data_transforms for mnist dataset
[ "data_transforms", "for", "mnist", "dataset" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L140-L163
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/utils.py
get_mean_and_std
def get_mean_and_std(dataset): """Compute the mean and std value of dataset.""" dataloader = torch.utils.data.DataLoader( dataset, batch_size=1, shuffle=True, num_workers=2 ) mean = torch.zeros(3) std = torch.zeros(3) print("==> Computing mean and std..") for inputs, _ in dataloader:...
python
def get_mean_and_std(dataset): """Compute the mean and std value of dataset.""" dataloader = torch.utils.data.DataLoader( dataset, batch_size=1, shuffle=True, num_workers=2 ) mean = torch.zeros(3) std = torch.zeros(3) print("==> Computing mean and std..") for inputs, _ in dataloader:...
[ "def", "get_mean_and_std", "(", "dataset", ")", ":", "dataloader", "=", "torch", ".", "utils", ".", "data", ".", "DataLoader", "(", "dataset", ",", "batch_size", "=", "1", ",", "shuffle", "=", "True", ",", "num_workers", "=", "2", ")", "mean", "=", "to...
Compute the mean and std value of dataset.
[ "Compute", "the", "mean", "and", "std", "value", "of", "dataset", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L166-L180
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/utils.py
init_params
def init_params(net): """Init layer parameters.""" for module in net.modules(): if isinstance(module, nn.Conv2d): init.kaiming_normal(module.weight, mode="fan_out") if module.bias: init.constant(module.bias, 0) elif isinstance(module, nn.BatchNorm2d): ...
python
def init_params(net): """Init layer parameters.""" for module in net.modules(): if isinstance(module, nn.Conv2d): init.kaiming_normal(module.weight, mode="fan_out") if module.bias: init.constant(module.bias, 0) elif isinstance(module, nn.BatchNorm2d): ...
[ "def", "init_params", "(", "net", ")", ":", "for", "module", "in", "net", ".", "modules", "(", ")", ":", "if", "isinstance", "(", "module", ",", "nn", ".", "Conv2d", ")", ":", "init", ".", "kaiming_normal", "(", "module", ".", "weight", ",", "mode", ...
Init layer parameters.
[ "Init", "layer", "parameters", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L183-L196
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/utils.py
EarlyStopping.step
def step(self, metrics): """ EarlyStopping step on each epoch Arguments: metrics {float} -- metric value """ if self.best is None: self.best = metrics return False if np.isnan(metrics): return True if self.is_better(metri...
python
def step(self, metrics): """ EarlyStopping step on each epoch Arguments: metrics {float} -- metric value """ if self.best is None: self.best = metrics return False if np.isnan(metrics): return True if self.is_better(metri...
[ "def", "step", "(", "self", ",", "metrics", ")", ":", "if", "self", ".", "best", "is", "None", ":", "self", ".", "best", "=", "metrics", "return", "False", "if", "np", ".", "isnan", "(", "metrics", ")", ":", "return", "True", "if", "self", ".", "...
EarlyStopping step on each epoch Arguments: metrics {float} -- metric value
[ "EarlyStopping", "step", "on", "each", "epoch", "Arguments", ":", "metrics", "{", "float", "}", "--", "metric", "value" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L43-L65
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
check_feasibility
def check_feasibility(x_bounds, lowerbound, upperbound): ''' This can have false positives. For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7. ''' # x_bounds should be sorted, so even for "discrete_int" type, # the smallest and the largest number should...
python
def check_feasibility(x_bounds, lowerbound, upperbound): ''' This can have false positives. For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7. ''' # x_bounds should be sorted, so even for "discrete_int" type, # the smallest and the largest number should...
[ "def", "check_feasibility", "(", "x_bounds", ",", "lowerbound", ",", "upperbound", ")", ":", "# x_bounds should be sorted, so even for \"discrete_int\" type,", "# the smallest and the largest number should the first and the last element", "x_bounds_lowerbound", "=", "sum", "(", "[", ...
This can have false positives. For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7.
[ "This", "can", "have", "false", "positives", ".", "For", "examples", "parameters", "can", "only", "be", "0", "or", "5", "and", "the", "summation", "constraint", "is", "between", "6", "and", "7", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py#L27-L40
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
rand
def rand(x_bounds, x_types, lowerbound, upperbound, max_retries=100): ''' Key idea is that we try to move towards upperbound, by randomly choose one value for each parameter. However, for the last parameter, we need to make sure that its value can help us get above lowerbound ''' outputs = None ...
python
def rand(x_bounds, x_types, lowerbound, upperbound, max_retries=100): ''' Key idea is that we try to move towards upperbound, by randomly choose one value for each parameter. However, for the last parameter, we need to make sure that its value can help us get above lowerbound ''' outputs = None ...
[ "def", "rand", "(", "x_bounds", ",", "x_types", ",", "lowerbound", ",", "upperbound", ",", "max_retries", "=", "100", ")", ":", "outputs", "=", "None", "if", "check_feasibility", "(", "x_bounds", ",", "lowerbound", ",", "upperbound", ")", "is", "True", ":"...
Key idea is that we try to move towards upperbound, by randomly choose one value for each parameter. However, for the last parameter, we need to make sure that its value can help us get above lowerbound
[ "Key", "idea", "is", "that", "we", "try", "to", "move", "towards", "upperbound", "by", "randomly", "choose", "one", "value", "for", "each", "parameter", ".", "However", "for", "the", "last", "parameter", "we", "need", "to", "make", "sure", "that", "its", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py#L42-L115
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
expand_path
def expand_path(experiment_config, key): '''Change '~' to user home directory''' if experiment_config.get(key): experiment_config[key] = os.path.expanduser(experiment_config[key])
python
def expand_path(experiment_config, key): '''Change '~' to user home directory''' if experiment_config.get(key): experiment_config[key] = os.path.expanduser(experiment_config[key])
[ "def", "expand_path", "(", "experiment_config", ",", "key", ")", ":", "if", "experiment_config", ".", "get", "(", "key", ")", ":", "experiment_config", "[", "key", "]", "=", "os", ".", "path", ".", "expanduser", "(", "experiment_config", "[", "key", "]", ...
Change '~' to user home directory
[ "Change", "~", "to", "user", "home", "directory" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L29-L32
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
parse_relative_path
def parse_relative_path(root_path, experiment_config, key): '''Change relative path to absolute path''' if experiment_config.get(key) and not os.path.isabs(experiment_config.get(key)): absolute_path = os.path.join(root_path, experiment_config.get(key)) print_normal('expand %s: %s to %s ' % (key,...
python
def parse_relative_path(root_path, experiment_config, key): '''Change relative path to absolute path''' if experiment_config.get(key) and not os.path.isabs(experiment_config.get(key)): absolute_path = os.path.join(root_path, experiment_config.get(key)) print_normal('expand %s: %s to %s ' % (key,...
[ "def", "parse_relative_path", "(", "root_path", ",", "experiment_config", ",", "key", ")", ":", "if", "experiment_config", ".", "get", "(", "key", ")", "and", "not", "os", ".", "path", ".", "isabs", "(", "experiment_config", ".", "get", "(", "key", ")", ...
Change relative path to absolute path
[ "Change", "relative", "path", "to", "absolute", "path" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L34-L39
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
parse_time
def parse_time(time): '''Change the time to seconds''' unit = time[-1] if unit not in ['s', 'm', 'h', 'd']: print_error('the unit of time could only from {s, m, h, d}') exit(1) time = time[:-1] if not time.isdigit(): print_error('time format error!') exit(1) parse...
python
def parse_time(time): '''Change the time to seconds''' unit = time[-1] if unit not in ['s', 'm', 'h', 'd']: print_error('the unit of time could only from {s, m, h, d}') exit(1) time = time[:-1] if not time.isdigit(): print_error('time format error!') exit(1) parse...
[ "def", "parse_time", "(", "time", ")", ":", "unit", "=", "time", "[", "-", "1", "]", "if", "unit", "not", "in", "[", "'s'", ",", "'m'", ",", "'h'", ",", "'d'", "]", ":", "print_error", "(", "'the unit of time could only from {s, m, h, d}'", ")", "exit", ...
Change the time to seconds
[ "Change", "the", "time", "to", "seconds" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L41-L52
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
parse_path
def parse_path(experiment_config, config_path): '''Parse path in config file''' expand_path(experiment_config, 'searchSpacePath') if experiment_config.get('trial'): expand_path(experiment_config['trial'], 'codeDir') if experiment_config.get('tuner'): expand_path(experiment_config['tuner'...
python
def parse_path(experiment_config, config_path): '''Parse path in config file''' expand_path(experiment_config, 'searchSpacePath') if experiment_config.get('trial'): expand_path(experiment_config['trial'], 'codeDir') if experiment_config.get('tuner'): expand_path(experiment_config['tuner'...
[ "def", "parse_path", "(", "experiment_config", ",", "config_path", ")", ":", "expand_path", "(", "experiment_config", ",", "'searchSpacePath'", ")", "if", "experiment_config", ".", "get", "(", "'trial'", ")", ":", "expand_path", "(", "experiment_config", "[", "'tr...
Parse path in config file
[ "Parse", "path", "in", "config", "file" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L54-L80
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_search_space_content
def validate_search_space_content(experiment_config): '''Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file''' try: search_space_content = json.load(open...
python
def validate_search_space_content(experiment_config): '''Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file''' try: search_space_content = json.load(open...
[ "def", "validate_search_space_content", "(", "experiment_config", ")", ":", "try", ":", "search_space_content", "=", "json", ".", "load", "(", "open", "(", "experiment_config", ".", "get", "(", "'searchSpacePath'", ")", ",", "'r'", ")", ")", "for", "value", "i...
Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file
[ "Validate", "searchspace", "content", "if", "the", "searchspace", "file", "is", "not", "json", "format", "or", "its", "values", "does", "not", "contain", "_type", "and", "_value", "which", "must", "be", "specified", "it", "will", "not", "be", "a", "valid", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L82-L94
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_kubeflow_operators
def validate_kubeflow_operators(experiment_config): '''Validate whether the kubeflow operators are valid''' if experiment_config.get('kubeflowConfig'): if experiment_config.get('kubeflowConfig').get('operator') == 'tf-operator': if experiment_config.get('trial').get('master') is not None: ...
python
def validate_kubeflow_operators(experiment_config): '''Validate whether the kubeflow operators are valid''' if experiment_config.get('kubeflowConfig'): if experiment_config.get('kubeflowConfig').get('operator') == 'tf-operator': if experiment_config.get('trial').get('master') is not None: ...
[ "def", "validate_kubeflow_operators", "(", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'kubeflowConfig'", ")", ":", "if", "experiment_config", ".", "get", "(", "'kubeflowConfig'", ")", ".", "get", "(", "'operator'", ")", "==", "'t...
Validate whether the kubeflow operators are valid
[ "Validate", "whether", "the", "kubeflow", "operators", "are", "valid" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L96-L125
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_common_content
def validate_common_content(experiment_config): '''Validate whether the common values in experiment_config is valid''' if not experiment_config.get('trainingServicePlatform') or \ experiment_config.get('trainingServicePlatform') not in ['local', 'remote', 'pai', 'kubeflow', 'frameworkcontroller']: ...
python
def validate_common_content(experiment_config): '''Validate whether the common values in experiment_config is valid''' if not experiment_config.get('trainingServicePlatform') or \ experiment_config.get('trainingServicePlatform') not in ['local', 'remote', 'pai', 'kubeflow', 'frameworkcontroller']: ...
[ "def", "validate_common_content", "(", "experiment_config", ")", ":", "if", "not", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "or", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "not", "in", "[", "'local'", ",",...
Validate whether the common values in experiment_config is valid
[ "Validate", "whether", "the", "common", "values", "in", "experiment_config", "is", "valid" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L127-L182
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_customized_file
def validate_customized_file(experiment_config, spec_key): ''' check whether the file of customized tuner/assessor/advisor exists spec_key: 'tuner', 'assessor', 'advisor' ''' if experiment_config[spec_key].get('codeDir') and \ experiment_config[spec_key].get('classFileName') and \ ex...
python
def validate_customized_file(experiment_config, spec_key): ''' check whether the file of customized tuner/assessor/advisor exists spec_key: 'tuner', 'assessor', 'advisor' ''' if experiment_config[spec_key].get('codeDir') and \ experiment_config[spec_key].get('classFileName') and \ ex...
[ "def", "validate_customized_file", "(", "experiment_config", ",", "spec_key", ")", ":", "if", "experiment_config", "[", "spec_key", "]", ".", "get", "(", "'codeDir'", ")", "and", "experiment_config", "[", "spec_key", "]", ".", "get", "(", "'classFileName'", ")",...
check whether the file of customized tuner/assessor/advisor exists spec_key: 'tuner', 'assessor', 'advisor'
[ "check", "whether", "the", "file", "of", "customized", "tuner", "/", "assessor", "/", "advisor", "exists", "spec_key", ":", "tuner", "assessor", "advisor" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L184-L199
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
parse_assessor_content
def parse_assessor_content(experiment_config): '''Validate whether assessor in experiment_config is valid''' if experiment_config.get('assessor'): if experiment_config['assessor'].get('builtinAssessorName'): experiment_config['assessor']['className'] = experiment_config['assessor']['builtinA...
python
def parse_assessor_content(experiment_config): '''Validate whether assessor in experiment_config is valid''' if experiment_config.get('assessor'): if experiment_config['assessor'].get('builtinAssessorName'): experiment_config['assessor']['className'] = experiment_config['assessor']['builtinA...
[ "def", "parse_assessor_content", "(", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'assessor'", ")", ":", "if", "experiment_config", "[", "'assessor'", "]", ".", "get", "(", "'builtinAssessorName'", ")", ":", "experiment_config", "["...
Validate whether assessor in experiment_config is valid
[ "Validate", "whether", "assessor", "in", "experiment_config", "is", "valid" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L208-L214
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_annotation_content
def validate_annotation_content(experiment_config, spec_key, builtin_name): ''' Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName' ''' if experiment_config.get('useAnnotation'): if experiment_...
python
def validate_annotation_content(experiment_config, spec_key, builtin_name): ''' Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName' ''' if experiment_config.get('useAnnotation'): if experiment_...
[ "def", "validate_annotation_content", "(", "experiment_config", ",", "spec_key", ",", "builtin_name", ")", ":", "if", "experiment_config", ".", "get", "(", "'useAnnotation'", ")", ":", "if", "experiment_config", ".", "get", "(", "'searchSpacePath'", ")", ":", "pri...
Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName'
[ "Valid", "whether", "useAnnotation", "and", "searchSpacePath", "is", "coexist", "spec_key", ":", "advisor", "or", "tuner", "builtin_name", ":", "builtinAdvisorName", "or", "builtinTunerName" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L223-L241
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_pai_trial_conifg
def validate_pai_trial_conifg(experiment_config): '''validate the trial config in pai platform''' if experiment_config.get('trainingServicePlatform') == 'pai': if experiment_config.get('trial').get('shmMB') and \ experiment_config['trial']['shmMB'] > experiment_config['trial']['memoryMB']: ...
python
def validate_pai_trial_conifg(experiment_config): '''validate the trial config in pai platform''' if experiment_config.get('trainingServicePlatform') == 'pai': if experiment_config.get('trial').get('shmMB') and \ experiment_config['trial']['shmMB'] > experiment_config['trial']['memoryMB']: ...
[ "def", "validate_pai_trial_conifg", "(", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "==", "'pai'", ":", "if", "experiment_config", ".", "get", "(", "'trial'", ")", ".", "get", "(", "'shmMB'", ")",...
validate the trial config in pai platform
[ "validate", "the", "trial", "config", "in", "pai", "platform" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L249-L255
train
Microsoft/nni
tools/nni_cmd/launcher_utils.py
validate_all_content
def validate_all_content(experiment_config, config_path): '''Validate whether experiment_config is valid''' parse_path(experiment_config, config_path) validate_common_content(experiment_config) validate_pai_trial_conifg(experiment_config) experiment_config['maxExecDuration'] = parse_time(experiment_...
python
def validate_all_content(experiment_config, config_path): '''Validate whether experiment_config is valid''' parse_path(experiment_config, config_path) validate_common_content(experiment_config) validate_pai_trial_conifg(experiment_config) experiment_config['maxExecDuration'] = parse_time(experiment_...
[ "def", "validate_all_content", "(", "experiment_config", ",", "config_path", ")", ":", "parse_path", "(", "experiment_config", ",", "config_path", ")", "validate_common_content", "(", "experiment_config", ")", "validate_pai_trial_conifg", "(", "experiment_config", ")", "e...
Validate whether experiment_config is valid
[ "Validate", "whether", "experiment_config", "is", "valid" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L257-L274
train
Microsoft/nni
tools/nni_cmd/url_utils.py
get_local_urls
def get_local_urls(port): '''get urls of local machine''' url_list = [] for name, info in psutil.net_if_addrs().items(): for addr in info: if AddressFamily.AF_INET == addr.family: url_list.append('http://{}:{}'.format(addr.address, port)) return url_list
python
def get_local_urls(port): '''get urls of local machine''' url_list = [] for name, info in psutil.net_if_addrs().items(): for addr in info: if AddressFamily.AF_INET == addr.family: url_list.append('http://{}:{}'.format(addr.address, port)) return url_list
[ "def", "get_local_urls", "(", "port", ")", ":", "url_list", "=", "[", "]", "for", "name", ",", "info", "in", "psutil", ".", "net_if_addrs", "(", ")", ".", "items", "(", ")", ":", "for", "addr", "in", "info", ":", "if", "AddressFamily", ".", "AF_INET"...
get urls of local machine
[ "get", "urls", "of", "local", "machine" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/url_utils.py#L76-L83
train
Microsoft/nni
tools/nni_annotation/code_generator.py
parse_annotation
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
python
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
[ "def", "parse_annotation", "(", "code", ")", ":", "module", "=", "ast", ".", "parse", "(", "code", ")", "assert", "type", "(", "module", ")", "is", "ast", ".", "Module", ",", "'internal error #1'", "assert", "len", "(", "module", ".", "body", ")", "=="...
Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@')
[ "Parse", "an", "annotation", "string", ".", "Return", "an", "AST", "Expr", "node", ".", "code", ":", "annotation", "string", "(", "excluding" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L29-L38
train
Microsoft/nni
tools/nni_annotation/code_generator.py
parse_annotation_function
def parse_annotation_function(code, func_name): """Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name """ expr = parse_annotation(code) call = expr.value assert type(call) is ast.Call, 'Annotation is not a functi...
python
def parse_annotation_function(code, func_name): """Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name """ expr = parse_annotation(code) call = expr.value assert type(call) is ast.Call, 'Annotation is not a functi...
[ "def", "parse_annotation_function", "(", "code", ",", "func_name", ")", ":", "expr", "=", "parse_annotation", "(", "code", ")", "call", "=", "expr", ".", "value", "assert", "type", "(", "call", ")", "is", "ast", ".", "Call", ",", "'Annotation is not a functi...
Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name
[ "Parse", "an", "annotation", "function", ".", "Return", "the", "value", "of", "name", "keyword", "argument", "and", "the", "AST", "Call", "node", ".", "func_name", ":", "expected", "function", "name" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L41-L59
train
Microsoft/nni
tools/nni_annotation/code_generator.py
parse_nni_variable
def parse_nni_variable(code): """Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string """ name, call = parse_annotation_function(code, 'variable') assert len(call.args) == 1, 'nni.variable contains more than one arguments' a...
python
def parse_nni_variable(code): """Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string """ name, call = parse_annotation_function(code, 'variable') assert len(call.args) == 1, 'nni.variable contains more than one arguments' a...
[ "def", "parse_nni_variable", "(", "code", ")", ":", "name", ",", "call", "=", "parse_annotation_function", "(", "code", ",", "'variable'", ")", "assert", "len", "(", "call", ".", "args", ")", "==", "1", ",", "'nni.variable contains more than one arguments'", "ar...
Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string
[ "Parse", "nni", ".", "variable", "expression", ".", "Return", "the", "name", "argument", "and", "AST", "node", "of", "annotated", "expression", ".", "code", ":", "annotation", "string" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L62-L82
train
Microsoft/nni
tools/nni_annotation/code_generator.py
parse_nni_function
def parse_nni_function(code): """Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string """ name, call = parse_annotation_function(code, 'function_choice') funcs = [ast.dump(func, False) for func...
python
def parse_nni_function(code): """Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string """ name, call = parse_annotation_function(code, 'function_choice') funcs = [ast.dump(func, False) for func...
[ "def", "parse_nni_function", "(", "code", ")", ":", "name", ",", "call", "=", "parse_annotation_function", "(", "code", ",", "'function_choice'", ")", "funcs", "=", "[", "ast", ".", "dump", "(", "func", ",", "False", ")", "for", "func", "in", "call", "."...
Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string
[ "Parse", "nni", ".", "function_choice", "expression", ".", "Return", "the", "AST", "node", "of", "annotated", "expression", "and", "a", "list", "of", "dumped", "function", "call", "expressions", ".", "code", ":", "annotation", "string" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L85-L97
train
Microsoft/nni
tools/nni_annotation/code_generator.py
convert_args_to_dict
def convert_args_to_dict(call, with_lambda=False): """Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary """ keys, values = list(), list() for arg in call.args: if type(ar...
python
def convert_args_to_dict(call, with_lambda=False): """Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary """ keys, values = list(), list() for arg in call.args: if type(ar...
[ "def", "convert_args_to_dict", "(", "call", ",", "with_lambda", "=", "False", ")", ":", "keys", ",", "values", "=", "list", "(", ")", ",", "list", "(", ")", "for", "arg", "in", "call", ".", "args", ":", "if", "type", "(", "arg", ")", "in", "[", "...
Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary
[ "Convert", "all", "args", "to", "a", "dict", "such", "that", "every", "key", "and", "value", "in", "the", "dict", "is", "the", "same", "as", "the", "value", "of", "the", "arg", ".", "Return", "the", "AST", "Call", "node", "with", "only", "one", "arg"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L100-L118
train
Microsoft/nni
tools/nni_annotation/code_generator.py
make_lambda
def make_lambda(call): """Wrap an AST Call node to lambda expression node. call: ast.Call node """ empty_args = ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]) return ast.Lambda(args=empty_args, body=call)
python
def make_lambda(call): """Wrap an AST Call node to lambda expression node. call: ast.Call node """ empty_args = ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]) return ast.Lambda(args=empty_args, body=call)
[ "def", "make_lambda", "(", "call", ")", ":", "empty_args", "=", "ast", ".", "arguments", "(", "args", "=", "[", "]", ",", "vararg", "=", "None", ",", "kwarg", "=", "None", ",", "defaults", "=", "[", "]", ")", "return", "ast", ".", "Lambda", "(", ...
Wrap an AST Call node to lambda expression node. call: ast.Call node
[ "Wrap", "an", "AST", "Call", "node", "to", "lambda", "expression", "node", ".", "call", ":", "ast", ".", "Call", "node" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L121-L126
train
Microsoft/nni
tools/nni_annotation/code_generator.py
replace_variable_node
def replace_variable_node(node, annotation): """Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string """ assert type(node) is ast.Assign, 'nni.variable is not annotating assignment expression' assert len(node.targets) == 1, 'Annotated assignment...
python
def replace_variable_node(node, annotation): """Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string """ assert type(node) is ast.Assign, 'nni.variable is not annotating assignment expression' assert len(node.targets) == 1, 'Annotated assignment...
[ "def", "replace_variable_node", "(", "node", ",", "annotation", ")", ":", "assert", "type", "(", "node", ")", "is", "ast", ".", "Assign", ",", "'nni.variable is not annotating assignment expression'", "assert", "len", "(", "node", ".", "targets", ")", "==", "1",...
Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string
[ "Replace", "a", "node", "annotated", "by", "nni", ".", "variable", ".", "node", ":", "the", "AST", "node", "to", "replace", "annotation", ":", "annotation", "string" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L148-L158
train
Microsoft/nni
tools/nni_annotation/code_generator.py
replace_function_node
def replace_function_node(node, annotation): """Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string """ target, funcs = parse_nni_function(annotation) FuncReplacer(funcs, target).visit(node) return node
python
def replace_function_node(node, annotation): """Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string """ target, funcs = parse_nni_function(annotation) FuncReplacer(funcs, target).visit(node) return node
[ "def", "replace_function_node", "(", "node", ",", "annotation", ")", ":", "target", ",", "funcs", "=", "parse_nni_function", "(", "annotation", ")", "FuncReplacer", "(", "funcs", ",", "target", ")", ".", "visit", "(", "node", ")", "return", "node" ]
Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string
[ "Replace", "a", "node", "annotated", "by", "nni", ".", "function_choice", ".", "node", ":", "the", "AST", "node", "to", "replace", "annotation", ":", "annotation", "string" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L161-L168
train
Microsoft/nni
tools/nni_annotation/code_generator.py
parse
def parse(code): """Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str) """ try: ast_tree = ast.parse(code) except Exception: raise RuntimeError('Bad Python code') transformer = Transformer() try: ...
python
def parse(code): """Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str) """ try: ast_tree = ast.parse(code) except Exception: raise RuntimeError('Bad Python code') transformer = Transformer() try: ...
[ "def", "parse", "(", "code", ")", ":", "try", ":", "ast_tree", "=", "ast", ".", "parse", "(", "code", ")", "except", "Exception", ":", "raise", "RuntimeError", "(", "'Bad Python code'", ")", "transformer", "=", "Transformer", "(", ")", "try", ":", "trans...
Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str)
[ "Annotate", "user", "code", ".", "Return", "annotated", "code", "(", "str", ")", "if", "annotation", "detected", ";", "return", "None", "if", "not", ".", "code", ":", "original", "user", "code", "(", "str", ")" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L254-L281
train
Microsoft/nni
src/sdk/pynni/nni/__main__.py
main
def main(): ''' main function. ''' args = parse_args() if args.multi_thread: enable_multi_thread() if args.advisor_class_name: # advisor is enabled and starts to run if args.multi_phase: raise AssertionError('multi_phase has not been supported in advisor') ...
python
def main(): ''' main function. ''' args = parse_args() if args.multi_thread: enable_multi_thread() if args.advisor_class_name: # advisor is enabled and starts to run if args.multi_phase: raise AssertionError('multi_phase has not been supported in advisor') ...
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "if", "args", ".", "multi_thread", ":", "enable_multi_thread", "(", ")", "if", "args", ".", "advisor_class_name", ":", "# advisor is enabled and starts to run", "if", "args", ".", "multi_phase", ...
main function.
[ "main", "function", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/__main__.py#L121-L198
train
Microsoft/nni
tools/nni_cmd/common_utils.py
get_yml_content
def get_yml_content(file_path): '''Load yaml file content''' try: with open(file_path, 'r') as file: return yaml.load(file, Loader=yaml.Loader) except yaml.scanner.ScannerError as err: print_error('yaml file format error!') exit(1) except Exception as exception: ...
python
def get_yml_content(file_path): '''Load yaml file content''' try: with open(file_path, 'r') as file: return yaml.load(file, Loader=yaml.Loader) except yaml.scanner.ScannerError as err: print_error('yaml file format error!') exit(1) except Exception as exception: ...
[ "def", "get_yml_content", "(", "file_path", ")", ":", "try", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "file", ":", "return", "yaml", ".", "load", "(", "file", ",", "Loader", "=", "yaml", ".", "Loader", ")", "except", "yaml", ".",...
Load yaml file content
[ "Load", "yaml", "file", "content" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/common_utils.py#L30-L40
train
Microsoft/nni
tools/nni_cmd/common_utils.py
detect_port
def detect_port(port): '''Detect if the port is used''' socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: socket_test.connect(('127.0.0.1', int(port))) socket_test.close() return True except: return False
python
def detect_port(port): '''Detect if the port is used''' socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: socket_test.connect(('127.0.0.1', int(port))) socket_test.close() return True except: return False
[ "def", "detect_port", "(", "port", ")", ":", "socket_test", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "try", ":", "socket_test", ".", "connect", "(", "(", "'127.0.0.1'", ",", "int", "(", "port", ...
Detect if the port is used
[ "Detect", "if", "the", "port", "is", "used" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/common_utils.py#L71-L79
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GMM/CreateModel.py
create_model
def create_model(samples_x, samples_y_aggregation, percentage_goodbatch=0.34): ''' Create the Gaussian Mixture Model ''' samples = [samples_x[i] + [samples_y_aggregation[i]] for i in range(0, len(samples_x))] # Sorts so that we can get the top samples samples = sorted(samples, key=itemgetter(-1...
python
def create_model(samples_x, samples_y_aggregation, percentage_goodbatch=0.34): ''' Create the Gaussian Mixture Model ''' samples = [samples_x[i] + [samples_y_aggregation[i]] for i in range(0, len(samples_x))] # Sorts so that we can get the top samples samples = sorted(samples, key=itemgetter(-1...
[ "def", "create_model", "(", "samples_x", ",", "samples_y_aggregation", ",", "percentage_goodbatch", "=", "0.34", ")", ":", "samples", "=", "[", "samples_x", "[", "i", "]", "+", "[", "samples_y_aggregation", "[", "i", "]", "]", "for", "i", "in", "range", "(...
Create the Gaussian Mixture Model
[ "Create", "the", "Gaussian", "Mixture", "Model" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/CreateModel.py#L30-L57
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
selection_r
def selection_r(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, num_starting_points=100, minimize_constraints_fun=None): ''' Selecte R value ''' minimize_starting_points = [lib_d...
python
def selection_r(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, num_starting_points=100, minimize_constraints_fun=None): ''' Selecte R value ''' minimize_starting_points = [lib_d...
[ "def", "selection_r", "(", "acquisition_function", ",", "samples_y_aggregation", ",", "x_bounds", ",", "x_types", ",", "regressor_gp", ",", "num_starting_points", "=", "100", ",", "minimize_constraints_fun", "=", "None", ")", ":", "minimize_starting_points", "=", "[",...
Selecte R value
[ "Selecte", "R", "value" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py#L37-L54
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
selection
def selection(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, minimize_starting_points, minimize_constraints_fun=None): ''' selection ''' outputs = None sys.stderr.write("[%s] Exercise \"%s\" acquisi...
python
def selection(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, minimize_starting_points, minimize_constraints_fun=None): ''' selection ''' outputs = None sys.stderr.write("[%s] Exercise \"%s\" acquisi...
[ "def", "selection", "(", "acquisition_function", ",", "samples_y_aggregation", ",", "x_bounds", ",", "x_types", ",", "regressor_gp", ",", "minimize_starting_points", ",", "minimize_constraints_fun", "=", "None", ")", ":", "outputs", "=", "None", "sys", ".", "stderr"...
selection
[ "selection" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py#L56-L83
train
Microsoft/nni
src/sdk/pynni/nni/trial.py
report_intermediate_result
def report_intermediate_result(metric): """Reports intermediate result to Assessor. metric: serializable object. """ global _intermediate_seq assert _params is not None, 'nni.get_next_parameter() needs to be called before report_intermediate_result' metric = json_tricks.dumps({ 'paramete...
python
def report_intermediate_result(metric): """Reports intermediate result to Assessor. metric: serializable object. """ global _intermediate_seq assert _params is not None, 'nni.get_next_parameter() needs to be called before report_intermediate_result' metric = json_tricks.dumps({ 'paramete...
[ "def", "report_intermediate_result", "(", "metric", ")", ":", "global", "_intermediate_seq", "assert", "_params", "is", "not", "None", ",", "'nni.get_next_parameter() needs to be called before report_intermediate_result'", "metric", "=", "json_tricks", ".", "dumps", "(", "{...
Reports intermediate result to Assessor. metric: serializable object.
[ "Reports", "intermediate", "result", "to", "Assessor", ".", "metric", ":", "serializable", "object", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/trial.py#L60-L74
train
Microsoft/nni
src/sdk/pynni/nni/trial.py
report_final_result
def report_final_result(metric): """Reports final result to tuner. metric: serializable object. """ assert _params is not None, 'nni.get_next_parameter() needs to be called before report_final_result' metric = json_tricks.dumps({ 'parameter_id': _params['parameter_id'], 'trial_job_id...
python
def report_final_result(metric): """Reports final result to tuner. metric: serializable object. """ assert _params is not None, 'nni.get_next_parameter() needs to be called before report_final_result' metric = json_tricks.dumps({ 'parameter_id': _params['parameter_id'], 'trial_job_id...
[ "def", "report_final_result", "(", "metric", ")", ":", "assert", "_params", "is", "not", "None", ",", "'nni.get_next_parameter() needs to be called before report_final_result'", "metric", "=", "json_tricks", ".", "dumps", "(", "{", "'parameter_id'", ":", "_params", "[",...
Reports final result to tuner. metric: serializable object.
[ "Reports", "final", "result", "to", "tuner", ".", "metric", ":", "serializable", "object", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/trial.py#L77-L89
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
get_args
def get_args(): """ get args from command line """ parser = argparse.ArgumentParser("FashionMNIST") parser.add_argument("--batch_size", type=int, default=128, help="batch size") parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer") parser.add_argument("--epochs", type=int...
python
def get_args(): """ get args from command line """ parser = argparse.ArgumentParser("FashionMNIST") parser.add_argument("--batch_size", type=int, default=128, help="batch size") parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer") parser.add_argument("--epochs", type=int...
[ "def", "get_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "\"FashionMNIST\"", ")", "parser", ".", "add_argument", "(", "\"--batch_size\"", ",", "type", "=", "int", ",", "default", "=", "128", ",", "help", "=", "\"batch size\"",...
get args from command line
[ "get", "args", "from", "command", "line" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L47-L62
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
build_graph_from_json
def build_graph_from_json(ir_model_json): """build model from json representation """ graph = json_to_graph(ir_model_json) logging.debug(graph.operation_history) model = graph.produce_torch_model() return model
python
def build_graph_from_json(ir_model_json): """build model from json representation """ graph = json_to_graph(ir_model_json) logging.debug(graph.operation_history) model = graph.produce_torch_model() return model
[ "def", "build_graph_from_json", "(", "ir_model_json", ")", ":", "graph", "=", "json_to_graph", "(", "ir_model_json", ")", "logging", ".", "debug", "(", "graph", ".", "operation_history", ")", "model", "=", "graph", ".", "produce_torch_model", "(", ")", "return",...
build model from json representation
[ "build", "model", "from", "json", "representation" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L75-L81
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
parse_rev_args
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") raw_train_data = torchvision.datasets.FashionMNIST( root="./d...
python
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") raw_train_data = torchvision.datasets.FashionMNIST( root="./d...
[ "def", "parse_rev_args", "(", "receive_msg", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "global", "criterion", "global", "optimizer", "# Loading Data", "logger", ".", "debug", "(", "\"Preparing data..\"", ")", "raw_train_data", "=", ...
parse reveive msgs to global variable
[ "parse", "reveive", "msgs", "to", "global", "variable" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L84-L145
train
Microsoft/nni
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
train
def train(epoch): """ train model on each epoch in trainset """ global trainloader global testloader global net global criterion global optimizer logger.debug("Epoch: %d", epoch) net.train() train_loss = 0 correct = 0 total = 0 for batch_idx, (inputs, targets) in e...
python
def train(epoch): """ train model on each epoch in trainset """ global trainloader global testloader global net global criterion global optimizer logger.debug("Epoch: %d", epoch) net.train() train_loss = 0 correct = 0 total = 0 for batch_idx, (inputs, targets) in e...
[ "def", "train", "(", "epoch", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "global", "criterion", "global", "optimizer", "logger", ".", "debug", "(", "\"Epoch: %d\"", ",", "epoch", ")", "net", ".", "train", "(", ")", "train_los...
train model on each epoch in trainset
[ "train", "model", "on", "each", "epoch", "in", "trainset" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L149-L188
train
Microsoft/nni
examples/trials/kaggle-tgs-salt/models.py
UNetResNetV4.freeze_bn
def freeze_bn(self): '''Freeze BatchNorm layers.''' for layer in self.modules(): if isinstance(layer, nn.BatchNorm2d): layer.eval()
python
def freeze_bn(self): '''Freeze BatchNorm layers.''' for layer in self.modules(): if isinstance(layer, nn.BatchNorm2d): layer.eval()
[ "def", "freeze_bn", "(", "self", ")", ":", "for", "layer", "in", "self", ".", "modules", "(", ")", ":", "if", "isinstance", "(", "layer", ",", "nn", ".", "BatchNorm2d", ")", ":", "layer", ".", "eval", "(", ")" ]
Freeze BatchNorm layers.
[ "Freeze", "BatchNorm", "layers", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/kaggle-tgs-salt/models.py#L210-L214
train
Microsoft/nni
examples/trials/network_morphism/cifar10/cifar10_pytorch.py
parse_rev_args
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") transform_train, transform_test = utils.data_transforms_cifar10(args)...
python
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") transform_train, transform_test = utils.data_transforms_cifar10(args)...
[ "def", "parse_rev_args", "(", "receive_msg", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "global", "criterion", "global", "optimizer", "# Loading Data", "logger", ".", "debug", "(", "\"Preparing data..\"", ")", "transform_train", ",", ...
parse reveive msgs to global variable
[ "parse", "reveive", "msgs", "to", "global", "variable" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/cifar10/cifar10_pytorch.py#L83-L136
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.prepare
def prepare(self, config_file=None, user=None, password=None, **kwargs): """登录的统一接口 :param config_file 登录数据文件,若无则选择参数登录模式 :param user: 各家券商的账号或者雪球的用户名 :param password: 密码, 券商为加密后的密码,雪球为明文密码 :param account: [雪球登录需要]雪球手机号(邮箱手机二选一) :param portfolio_code: [雪球登录需要]组合代码 ...
python
def prepare(self, config_file=None, user=None, password=None, **kwargs): """登录的统一接口 :param config_file 登录数据文件,若无则选择参数登录模式 :param user: 各家券商的账号或者雪球的用户名 :param password: 密码, 券商为加密后的密码,雪球为明文密码 :param account: [雪球登录需要]雪球手机号(邮箱手机二选一) :param portfolio_code: [雪球登录需要]组合代码 ...
[ "def", "prepare", "(", "self", ",", "config_file", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "config_file", "is", "not", "None", ":", "self", ".", "read_config", "(", "config_file", ...
登录的统一接口 :param config_file 登录数据文件,若无则选择参数登录模式 :param user: 各家券商的账号或者雪球的用户名 :param password: 密码, 券商为加密后的密码,雪球为明文密码 :param account: [雪球登录需要]雪球手机号(邮箱手机二选一) :param portfolio_code: [雪球登录需要]组合代码 :param portfolio_market: [雪球登录需要]交易市场, 可选['cn', 'us', 'hk'] 默认 'cn'
[ "登录的统一接口", ":", "param", "config_file", "登录数据文件,若无则选择参数登录模式", ":", "param", "user", ":", "各家券商的账号或者雪球的用户名", ":", "param", "password", ":", "密码", "券商为加密后的密码,雪球为明文密码", ":", "param", "account", ":", "[", "雪球登录需要", "]", "雪球手机号", "(", "邮箱手机二选一", ")", ":", "param", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L40-L54
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.autologin
def autologin(self, limit=10): """实现自动登录 :param limit: 登录次数限制 """ for _ in range(limit): if self.login(): break else: raise exceptions.NotLoginError( "登录失败次数过多, 请检查密码是否正确 / 券商服务器是否处于维护中 / 网络连接是否正常" ) self...
python
def autologin(self, limit=10): """实现自动登录 :param limit: 登录次数限制 """ for _ in range(limit): if self.login(): break else: raise exceptions.NotLoginError( "登录失败次数过多, 请检查密码是否正确 / 券商服务器是否处于维护中 / 网络连接是否正常" ) self...
[ "def", "autologin", "(", "self", ",", "limit", "=", "10", ")", ":", "for", "_", "in", "range", "(", "limit", ")", ":", "if", "self", ".", "login", "(", ")", ":", "break", "else", ":", "raise", "exceptions", ".", "NotLoginError", "(", "\"登录失败次数过多, 请检查...
实现自动登录 :param limit: 登录次数限制
[ "实现自动登录", ":", "param", "limit", ":", "登录次数限制" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L60-L71
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.keepalive
def keepalive(self): """启动保持在线的进程 """ if self.heart_thread.is_alive(): self.heart_active = True else: self.heart_thread.start()
python
def keepalive(self): """启动保持在线的进程 """ if self.heart_thread.is_alive(): self.heart_active = True else: self.heart_thread.start()
[ "def", "keepalive", "(", "self", ")", ":", "if", "self", ".", "heart_thread", ".", "is_alive", "(", ")", ":", "self", ".", "heart_active", "=", "True", "else", ":", "self", ".", "heart_thread", ".", "start", "(", ")" ]
启动保持在线的进程
[ "启动保持在线的进程" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L76-L81
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.__read_config
def __read_config(self): """读取 config""" self.config = helpers.file2dict(self.config_path) self.global_config = helpers.file2dict(self.global_config_path) self.config.update(self.global_config)
python
def __read_config(self): """读取 config""" self.config = helpers.file2dict(self.config_path) self.global_config = helpers.file2dict(self.global_config_path) self.config.update(self.global_config)
[ "def", "__read_config", "(", "self", ")", ":", "self", ".", "config", "=", "helpers", ".", "file2dict", "(", "self", ".", "config_path", ")", "self", ".", "global_config", "=", "helpers", ".", "file2dict", "(", "self", ".", "global_config_path", ")", "self...
读取 config
[ "读取", "config" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L116-L120
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.exchangebill
def exchangebill(self): """ 默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。 :return: """ # TODO 目前仅在 华泰子类 中实现 start_date, end_date = helpers.get_30_date() return self.get_exchangebill(start_date, end_date)
python
def exchangebill(self): """ 默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。 :return: """ # TODO 目前仅在 华泰子类 中实现 start_date, end_date = helpers.get_30_date() return self.get_exchangebill(start_date, end_date)
[ "def", "exchangebill", "(", "self", ")", ":", "# TODO 目前仅在 华泰子类 中实现", "start_date", ",", "end_date", "=", "helpers", ".", "get_30_date", "(", ")", "return", "self", ".", "get_exchangebill", "(", "start_date", ",", "end_date", ")" ]
默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。 :return:
[ "默认提供最近30天的交割单", "通常只能返回查询日期内最新的", "90", "天数据。", ":", "return", ":" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L156-L163
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.do
def do(self, params): """发起对 api 的请求并过滤返回结果 :param params: 交易所需的动态参数""" request_params = self.create_basic_params() request_params.update(params) response_data = self.request(request_params) try: format_json_data = self.format_response_data(response_data) ...
python
def do(self, params): """发起对 api 的请求并过滤返回结果 :param params: 交易所需的动态参数""" request_params = self.create_basic_params() request_params.update(params) response_data = self.request(request_params) try: format_json_data = self.format_response_data(response_data) ...
[ "def", "do", "(", "self", ",", "params", ")", ":", "request_params", "=", "self", ".", "create_basic_params", "(", ")", "request_params", ".", "update", "(", "params", ")", "response_data", "=", "self", ".", "request", "(", "request_params", ")", "try", ":...
发起对 api 的请求并过滤返回结果 :param params: 交易所需的动态参数
[ "发起对", "api", "的请求并过滤返回结果", ":", "param", "params", ":", "交易所需的动态参数" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L182-L199
train
shidenggui/easytrader
easytrader/webtrader.py
WebTrader.format_response_data_type
def format_response_data_type(self, response_data): """格式化返回的值为正确的类型 :param response_data: 返回的数据 """ if isinstance(response_data, list) and not isinstance( response_data, str ): return response_data int_match_str = "|".join(self.config["response_f...
python
def format_response_data_type(self, response_data): """格式化返回的值为正确的类型 :param response_data: 返回的数据 """ if isinstance(response_data, list) and not isinstance( response_data, str ): return response_data int_match_str = "|".join(self.config["response_f...
[ "def", "format_response_data_type", "(", "self", ",", "response_data", ")", ":", "if", "isinstance", "(", "response_data", ",", "list", ")", "and", "not", "isinstance", "(", "response_data", ",", "str", ")", ":", "return", "response_data", "int_match_str", "=", ...
格式化返回的值为正确的类型 :param response_data: 返回的数据
[ "格式化返回的值为正确的类型", ":", "param", "response_data", ":", "返回的数据" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L220-L240
train
shidenggui/easytrader
easytrader/remoteclient.py
RemoteClient.prepare
def prepare( self, config_path=None, user=None, password=None, exe_path=None, comm_password=None, **kwargs ): """ 登陆客户端 :param config_path: 登陆配置文件,跟参数登陆方式二选一 :param user: 账号 :param password: 明文密码 :param exe_path:...
python
def prepare( self, config_path=None, user=None, password=None, exe_path=None, comm_password=None, **kwargs ): """ 登陆客户端 :param config_path: 登陆配置文件,跟参数登陆方式二选一 :param user: 账号 :param password: 明文密码 :param exe_path:...
[ "def", "prepare", "(", "self", ",", "config_path", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "exe_path", "=", "None", ",", "comm_password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "locals", "(", ...
登陆客户端 :param config_path: 登陆配置文件,跟参数登陆方式二选一 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 r'C:\\htzqzyb2\\xiadan.exe', 默认 r'C:\\htzqzyb2\\xiadan.exe' :param comm_password: 通讯密码 :return:
[ "登陆客户端", ":", "param", "config_path", ":", "登陆配置文件,跟参数登陆方式二选一", ":", "param", "user", ":", "账号", ":", "param", "password", ":", "明文密码", ":", "param", "exe_path", ":", "客户端路径类似", "r", "C", ":", "\\\\", "htzqzyb2", "\\\\", "xiadan", ".", "exe", "默认", "r", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/remoteclient.py#L17-L48
train
shidenggui/easytrader
easytrader/ricequant_follower.py
RiceQuantFollower.follow
def follow( self, users, run_id, track_interval=1, trade_cmd_expire_seconds=120, cmd_cache=True, entrust_prop="limit", send_interval=0, ): """跟踪ricequant对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param run_...
python
def follow( self, users, run_id, track_interval=1, trade_cmd_expire_seconds=120, cmd_cache=True, entrust_prop="limit", send_interval=0, ): """跟踪ricequant对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param run_...
[ "def", "follow", "(", "self", ",", "users", ",", "run_id", ",", "track_interval", "=", "1", ",", "trade_cmd_expire_seconds", "=", "120", ",", "cmd_cache", "=", "True", ",", "entrust_prop", "=", "\"limit\"", ",", "send_interval", "=", "0", ",", ")", ":", ...
跟踪ricequant对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param run_id: ricequant 的模拟交易ID,支持使用 [] 指定多个模拟交易 :param track_interval: 轮训模拟交易时间,单位为秒 :param trade_cmd_expire_seconds: 交易指令过期时间, 单位为秒 :param cmd_cache: 是否读取存储历史执行过的指令,防止重启时重复执行已经交易过的指令 :param entr...
[ "跟踪ricequant对应的模拟交易,支持多用户多策略", ":", "param", "users", ":", "支持easytrader的用户对象,支持使用", "[]", "指定多个用户", ":", "param", "run_id", ":", "ricequant", "的模拟交易ID,支持使用", "[]", "指定多个模拟交易", ":", "param", "track_interval", ":", "轮训模拟交易时间,单位为秒", ":", "param", "trade_cmd_expire_seconds...
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/ricequant_follower.py#L20-L61
train
shidenggui/easytrader
easytrader/gj_clienttrader.py
GJClientTrader.login
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ 登陆客户端 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 'C:\\中国银河证券双子星3.2\\Binarystar.exe', 默认 'C:\\中国银河证券双子星3.2\\Binarystar.exe' :param comm_password: 通讯密码, 华泰需要,可不设 ...
python
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ 登陆客户端 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 'C:\\中国银河证券双子星3.2\\Binarystar.exe', 默认 'C:\\中国银河证券双子星3.2\\Binarystar.exe' :param comm_password: 通讯密码, 华泰需要,可不设 ...
[ "def", "login", "(", "self", ",", "user", ",", "password", ",", "exe_path", ",", "comm_password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_app", "=", "pywinauto", ".", "Application", "(", ")", ".", "connect", "(", ...
登陆客户端 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 'C:\\中国银河证券双子星3.2\\Binarystar.exe', 默认 'C:\\中国银河证券双子星3.2\\Binarystar.exe' :param comm_password: 通讯密码, 华泰需要,可不设 :return:
[ "登陆客户端" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/gj_clienttrader.py#L17-L69
train
shidenggui/easytrader
easytrader/ht_clienttrader.py
HTClientTrader.login
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ :param user: 用户名 :param password: 密码 :param exe_path: 客户端路径, 类似 :param comm_password: :param kwargs: :return: """ if comm_password is None: raise Val...
python
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ :param user: 用户名 :param password: 密码 :param exe_path: 客户端路径, 类似 :param comm_password: :param kwargs: :return: """ if comm_password is None: raise Val...
[ "def", "login", "(", "self", ",", "user", ",", "password", ",", "exe_path", ",", "comm_password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "comm_password", "is", "None", ":", "raise", "ValueError", "(", "\"华泰必须设置通讯密码\")\r", "", "try", ":", ...
:param user: 用户名 :param password: 密码 :param exe_path: 客户端路径, 类似 :param comm_password: :param kwargs: :return:
[ ":", "param", "user", ":", "用户名", ":", "param", "password", ":", "密码", ":", "param", "exe_path", ":", "客户端路径", "类似", ":", "param", "comm_password", ":", ":", "param", "kwargs", ":", ":", "return", ":" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/ht_clienttrader.py#L13-L55
train