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/networkmorphism_tuner/graph.py
Graph._insert_new_layers
def _insert_new_layers(self, new_layers, start_node_id, end_node_id): """Insert the new_layers after the node with start_node_id.""" new_node_id = self._add_node(deepcopy(self.node_list[end_node_id])) temp_output_id = new_node_id for layer in new_layers[:-1]: temp_output_id =...
python
def _insert_new_layers(self, new_layers, start_node_id, end_node_id): """Insert the new_layers after the node with start_node_id.""" new_node_id = self._add_node(deepcopy(self.node_list[end_node_id])) temp_output_id = new_node_id for layer in new_layers[:-1]: temp_output_id =...
[ "def", "_insert_new_layers", "(", "self", ",", "new_layers", ",", "start_node_id", ",", "end_node_id", ")", ":", "new_node_id", "=", "self", ".", "_add_node", "(", "deepcopy", "(", "self", ".", "node_list", "[", "end_node_id", "]", ")", ")", "temp_output_id", ...
Insert the new_layers after the node with start_node_id.
[ "Insert", "the", "new_layers", "after", "the", "node", "with", "start_node_id", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L438-L448
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
Graph.to_add_skip_model
def to_add_skip_model(self, start_id, end_id): """Add a weighted add skip-connection from after start node to end node. Args: start_id: The convolutional layer ID, after which to start the skip-connection. end_id: The convolutional layer ID, after which to end the skip-connection...
python
def to_add_skip_model(self, start_id, end_id): """Add a weighted add skip-connection from after start node to end node. Args: start_id: The convolutional layer ID, after which to start the skip-connection. end_id: The convolutional layer ID, after which to end the skip-connection...
[ "def", "to_add_skip_model", "(", "self", ",", "start_id", ",", "end_id", ")", ":", "self", ".", "operation_history", ".", "append", "(", "(", "\"to_add_skip_model\"", ",", "start_id", ",", "end_id", ")", ")", "filters_end", "=", "self", ".", "layer_list", "[...
Add a weighted add skip-connection from after start node to end node. Args: start_id: The convolutional layer ID, after which to start the skip-connection. end_id: The convolutional layer ID, after which to end the skip-connection.
[ "Add", "a", "weighted", "add", "skip", "-", "connection", "from", "after", "start", "node", "to", "end", "node", ".", "Args", ":", "start_id", ":", "The", "convolutional", "layer", "ID", "after", "which", "to", "start", "the", "skip", "-", "connection", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L467-L508
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
Graph.to_concat_skip_model
def to_concat_skip_model(self, start_id, end_id): """Add a weighted add concatenate connection from after start node to end node. Args: start_id: The convolutional layer ID, after which to start the skip-connection. end_id: The convolutional layer ID, after which to end the skip-...
python
def to_concat_skip_model(self, start_id, end_id): """Add a weighted add concatenate connection from after start node to end node. Args: start_id: The convolutional layer ID, after which to start the skip-connection. end_id: The convolutional layer ID, after which to end the skip-...
[ "def", "to_concat_skip_model", "(", "self", ",", "start_id", ",", "end_id", ")", ":", "self", ".", "operation_history", ".", "append", "(", "(", "\"to_concat_skip_model\"", ",", "start_id", ",", "end_id", ")", ")", "filters_end", "=", "self", ".", "layer_list"...
Add a weighted add concatenate connection from after start node to end node. Args: start_id: The convolutional layer ID, after which to start the skip-connection. end_id: The convolutional layer ID, after which to end the skip-connection.
[ "Add", "a", "weighted", "add", "concatenate", "connection", "from", "after", "start", "node", "to", "end", "node", ".", "Args", ":", "start_id", ":", "The", "convolutional", "layer", "ID", "after", "which", "to", "start", "the", "skip", "-", "connection", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L510-L563
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
Graph.extract_descriptor
def extract_descriptor(self): """Extract the the description of the Graph as an instance of NetworkDescriptor.""" main_chain = self.get_main_chain() index_in_main_chain = {} for index, u in enumerate(main_chain): index_in_main_chain[u] = index ret = NetworkDescriptor...
python
def extract_descriptor(self): """Extract the the description of the Graph as an instance of NetworkDescriptor.""" main_chain = self.get_main_chain() index_in_main_chain = {} for index, u in enumerate(main_chain): index_in_main_chain[u] = index ret = NetworkDescriptor...
[ "def", "extract_descriptor", "(", "self", ")", ":", "main_chain", "=", "self", ".", "get_main_chain", "(", ")", "index_in_main_chain", "=", "{", "}", "for", "index", ",", "u", "in", "enumerate", "(", "main_chain", ")", ":", "index_in_main_chain", "[", "u", ...
Extract the the description of the Graph as an instance of NetworkDescriptor.
[ "Extract", "the", "the", "description", "of", "the", "Graph", "as", "an", "instance", "of", "NetworkDescriptor", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L580-L625
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
Graph.clear_weights
def clear_weights(self): ''' clear weights of the graph ''' self.weighted = False for layer in self.layer_list: layer.weights = None
python
def clear_weights(self): ''' clear weights of the graph ''' self.weighted = False for layer in self.layer_list: layer.weights = None
[ "def", "clear_weights", "(", "self", ")", ":", "self", ".", "weighted", "=", "False", "for", "layer", "in", "self", ".", "layer_list", ":", "layer", ".", "weights", "=", "None" ]
clear weights of the graph
[ "clear", "weights", "of", "the", "graph" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L627-L632
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
Graph.get_main_chain_layers
def get_main_chain_layers(self): """Return a list of layer IDs in the main chain.""" main_chain = self.get_main_chain() ret = [] for u in main_chain: for v, layer_id in self.adj_list[u]: if v in main_chain and u in main_chain: ret.append(la...
python
def get_main_chain_layers(self): """Return a list of layer IDs in the main chain.""" main_chain = self.get_main_chain() ret = [] for u in main_chain: for v, layer_id in self.adj_list[u]: if v in main_chain and u in main_chain: ret.append(la...
[ "def", "get_main_chain_layers", "(", "self", ")", ":", "main_chain", "=", "self", ".", "get_main_chain", "(", ")", "ret", "=", "[", "]", "for", "u", "in", "main_chain", ":", "for", "v", ",", "layer_id", "in", "self", ".", "adj_list", "[", "u", "]", "...
Return a list of layer IDs in the main chain.
[ "Return", "a", "list", "of", "layer", "IDs", "in", "the", "main", "chain", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L680-L688
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph.py
Graph.get_main_chain
def get_main_chain(self): """Returns the main chain node ID list.""" pre_node = {} distance = {} for i in range(self.n_nodes): distance[i] = 0 pre_node[i] = i for i in range(self.n_nodes - 1): for u in range(self.n_nodes): for v...
python
def get_main_chain(self): """Returns the main chain node ID list.""" pre_node = {} distance = {} for i in range(self.n_nodes): distance[i] = 0 pre_node[i] = i for i in range(self.n_nodes - 1): for u in range(self.n_nodes): for v...
[ "def", "get_main_chain", "(", "self", ")", ":", "pre_node", "=", "{", "}", "distance", "=", "{", "}", "for", "i", "in", "range", "(", "self", ".", "n_nodes", ")", ":", "distance", "[", "i", "]", "=", "0", "pre_node", "[", "i", "]", "=", "i", "f...
Returns the main chain node ID list.
[ "Returns", "the", "main", "chain", "node", "ID", "list", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph.py#L723-L748
train
Microsoft/nni
src/sdk/pynni/nni/msg_dispatcher_base.py
MsgDispatcherBase.run
def run(self): """Run the tuner. This function will never return unless raise. """ _logger.info('Start dispatcher') if dispatcher_env_vars.NNI_MODE == 'resume': self.load_checkpoint() while True: command, data = receive() if data: ...
python
def run(self): """Run the tuner. This function will never return unless raise. """ _logger.info('Start dispatcher') if dispatcher_env_vars.NNI_MODE == 'resume': self.load_checkpoint() while True: command, data = receive() if data: ...
[ "def", "run", "(", "self", ")", ":", "_logger", ".", "info", "(", "'Start dispatcher'", ")", "if", "dispatcher_env_vars", ".", "NNI_MODE", "==", "'resume'", ":", "self", ".", "load_checkpoint", "(", ")", "while", "True", ":", "command", ",", "data", "=", ...
Run the tuner. This function will never return unless raise.
[ "Run", "the", "tuner", ".", "This", "function", "will", "never", "return", "unless", "raise", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/msg_dispatcher_base.py#L57-L92
train
Microsoft/nni
src/sdk/pynni/nni/msg_dispatcher_base.py
MsgDispatcherBase.command_queue_worker
def command_queue_worker(self, command_queue): """Process commands in command queues. """ while True: try: # set timeout to ensure self.stopping is checked periodically command, data = command_queue.get(timeout=3) try: ...
python
def command_queue_worker(self, command_queue): """Process commands in command queues. """ while True: try: # set timeout to ensure self.stopping is checked periodically command, data = command_queue.get(timeout=3) try: ...
[ "def", "command_queue_worker", "(", "self", ",", "command_queue", ")", ":", "while", "True", ":", "try", ":", "# set timeout to ensure self.stopping is checked periodically", "command", ",", "data", "=", "command_queue", ".", "get", "(", "timeout", "=", "3", ")", ...
Process commands in command queues.
[ "Process", "commands", "in", "command", "queues", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/msg_dispatcher_base.py#L94-L110
train
Microsoft/nni
src/sdk/pynni/nni/msg_dispatcher_base.py
MsgDispatcherBase.enqueue_command
def enqueue_command(self, command, data): """Enqueue command into command queues """ if command == CommandType.TrialEnd or (command == CommandType.ReportMetricData and data['type'] == 'PERIODICAL'): self.assessor_command_queue.put((command, data)) else: self.defau...
python
def enqueue_command(self, command, data): """Enqueue command into command queues """ if command == CommandType.TrialEnd or (command == CommandType.ReportMetricData and data['type'] == 'PERIODICAL'): self.assessor_command_queue.put((command, data)) else: self.defau...
[ "def", "enqueue_command", "(", "self", ",", "command", ",", "data", ")", ":", "if", "command", "==", "CommandType", ".", "TrialEnd", "or", "(", "command", "==", "CommandType", ".", "ReportMetricData", "and", "data", "[", "'type'", "]", "==", "'PERIODICAL'", ...
Enqueue command into command queues
[ "Enqueue", "command", "into", "command", "queues" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/msg_dispatcher_base.py#L112-L126
train
Microsoft/nni
src/sdk/pynni/nni/msg_dispatcher_base.py
MsgDispatcherBase.process_command_thread
def process_command_thread(self, request): """Worker thread to process a command. """ command, data = request if multi_thread_enabled(): try: self.process_command(command, data) except Exception as e: _logger.exception(str(e)) ...
python
def process_command_thread(self, request): """Worker thread to process a command. """ command, data = request if multi_thread_enabled(): try: self.process_command(command, data) except Exception as e: _logger.exception(str(e)) ...
[ "def", "process_command_thread", "(", "self", ",", "request", ")", ":", "command", ",", "data", "=", "request", "if", "multi_thread_enabled", "(", ")", ":", "try", ":", "self", ".", "process_command", "(", "command", ",", "data", ")", "except", "Exception", ...
Worker thread to process a command.
[ "Worker", "thread", "to", "process", "a", "command", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/msg_dispatcher_base.py#L128-L139
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/lib_data.py
match_val_type
def match_val_type(vals, vals_bounds, vals_types): ''' Update values in the array, to match their corresponding type ''' vals_new = [] for i, _ in enumerate(vals_types): if vals_types[i] == "discrete_int": # Find the closest integer in the array, vals_bounds vals_new...
python
def match_val_type(vals, vals_bounds, vals_types): ''' Update values in the array, to match their corresponding type ''' vals_new = [] for i, _ in enumerate(vals_types): if vals_types[i] == "discrete_int": # Find the closest integer in the array, vals_bounds vals_new...
[ "def", "match_val_type", "(", "vals", ",", "vals_bounds", ",", "vals_types", ")", ":", "vals_new", "=", "[", "]", "for", "i", ",", "_", "in", "enumerate", "(", "vals_types", ")", ":", "if", "vals_types", "[", "i", "]", "==", "\"discrete_int\"", ":", "#...
Update values in the array, to match their corresponding type
[ "Update", "values", "in", "the", "array", "to", "match", "their", "corresponding", "type" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_data.py#L25-L44
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/lib_data.py
rand
def rand(x_bounds, x_types): ''' Random generate variable value within their bounds ''' outputs = [] for i, _ in enumerate(x_bounds): if x_types[i] == "discrete_int": temp = x_bounds[i][random.randint(0, len(x_bounds[i]) - 1)] outputs.append(temp) elif x_type...
python
def rand(x_bounds, x_types): ''' Random generate variable value within their bounds ''' outputs = [] for i, _ in enumerate(x_bounds): if x_types[i] == "discrete_int": temp = x_bounds[i][random.randint(0, len(x_bounds[i]) - 1)] outputs.append(temp) elif x_type...
[ "def", "rand", "(", "x_bounds", ",", "x_types", ")", ":", "outputs", "=", "[", "]", "for", "i", ",", "_", "in", "enumerate", "(", "x_bounds", ")", ":", "if", "x_types", "[", "i", "]", "==", "\"discrete_int\"", ":", "temp", "=", "x_bounds", "[", "i"...
Random generate variable value within their bounds
[ "Random", "generate", "variable", "value", "within", "their", "bounds" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_data.py#L47-L66
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
to_wider_graph
def to_wider_graph(graph): ''' wider graph ''' weighted_layer_ids = graph.wide_layer_ids() weighted_layer_ids = list( filter(lambda x: graph.layer_list[x].output.shape[-1], weighted_layer_ids) ) wider_layers = sample(weighted_layer_ids, 1) for layer_id in wider_layers: layer...
python
def to_wider_graph(graph): ''' wider graph ''' weighted_layer_ids = graph.wide_layer_ids() weighted_layer_ids = list( filter(lambda x: graph.layer_list[x].output.shape[-1], weighted_layer_ids) ) wider_layers = sample(weighted_layer_ids, 1) for layer_id in wider_layers: layer...
[ "def", "to_wider_graph", "(", "graph", ")", ":", "weighted_layer_ids", "=", "graph", ".", "wide_layer_ids", "(", ")", "weighted_layer_ids", "=", "list", "(", "filter", "(", "lambda", "x", ":", "graph", ".", "layer_list", "[", "x", "]", ".", "output", ".", ...
wider graph
[ "wider", "graph" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L38-L55
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
to_skip_connection_graph
def to_skip_connection_graph(graph): ''' skip connection graph ''' # The last conv layer cannot be widen since wider operator cannot be done over the two sides of flatten. weighted_layer_ids = graph.skip_connection_layer_ids() valid_connection = [] for skip_type in sorted([NetworkDescriptor.ADD_...
python
def to_skip_connection_graph(graph): ''' skip connection graph ''' # The last conv layer cannot be widen since wider operator cannot be done over the two sides of flatten. weighted_layer_ids = graph.skip_connection_layer_ids() valid_connection = [] for skip_type in sorted([NetworkDescriptor.ADD_...
[ "def", "to_skip_connection_graph", "(", "graph", ")", ":", "# The last conv layer cannot be widen since wider operator cannot be done over the two sides of flatten.", "weighted_layer_ids", "=", "graph", ".", "skip_connection_layer_ids", "(", ")", "valid_connection", "=", "[", "]", ...
skip connection graph
[ "skip", "connection", "graph" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L58-L78
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
create_new_layer
def create_new_layer(layer, n_dim): ''' create new layer for the graph ''' input_shape = layer.output.shape dense_deeper_classes = [StubDense, get_dropout_class(n_dim), StubReLU] conv_deeper_classes = [get_conv_class(n_dim), get_batch_norm_class(n_dim), StubReLU] if is_layer(layer, "ReLU"): ...
python
def create_new_layer(layer, n_dim): ''' create new layer for the graph ''' input_shape = layer.output.shape dense_deeper_classes = [StubDense, get_dropout_class(n_dim), StubReLU] conv_deeper_classes = [get_conv_class(n_dim), get_batch_norm_class(n_dim), StubReLU] if is_layer(layer, "ReLU"): ...
[ "def", "create_new_layer", "(", "layer", ",", "n_dim", ")", ":", "input_shape", "=", "layer", ".", "output", ".", "shape", "dense_deeper_classes", "=", "[", "StubDense", ",", "get_dropout_class", "(", "n_dim", ")", ",", "StubReLU", "]", "conv_deeper_classes", ...
create new layer for the graph
[ "create", "new", "layer", "for", "the", "graph" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L81-L124
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
to_deeper_graph
def to_deeper_graph(graph): ''' deeper graph ''' weighted_layer_ids = graph.deep_layer_ids() if len(weighted_layer_ids) >= Constant.MAX_LAYERS: return None deeper_layer_ids = sample(weighted_layer_ids, 1) for layer_id in deeper_layer_ids: layer = graph.layer_list[layer_id] ...
python
def to_deeper_graph(graph): ''' deeper graph ''' weighted_layer_ids = graph.deep_layer_ids() if len(weighted_layer_ids) >= Constant.MAX_LAYERS: return None deeper_layer_ids = sample(weighted_layer_ids, 1) for layer_id in deeper_layer_ids: layer = graph.layer_list[layer_id] ...
[ "def", "to_deeper_graph", "(", "graph", ")", ":", "weighted_layer_ids", "=", "graph", ".", "deep_layer_ids", "(", ")", "if", "len", "(", "weighted_layer_ids", ")", ">=", "Constant", ".", "MAX_LAYERS", ":", "return", "None", "deeper_layer_ids", "=", "sample", "...
deeper graph
[ "deeper", "graph" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L127-L141
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
legal_graph
def legal_graph(graph): '''judge if a graph is legal or not. ''' descriptor = graph.extract_descriptor() skips = descriptor.skip_connections if len(skips) != len(set(skips)): return False return True
python
def legal_graph(graph): '''judge if a graph is legal or not. ''' descriptor = graph.extract_descriptor() skips = descriptor.skip_connections if len(skips) != len(set(skips)): return False return True
[ "def", "legal_graph", "(", "graph", ")", ":", "descriptor", "=", "graph", ".", "extract_descriptor", "(", ")", "skips", "=", "descriptor", ".", "skip_connections", "if", "len", "(", "skips", ")", "!=", "len", "(", "set", "(", "skips", ")", ")", ":", "r...
judge if a graph is legal or not.
[ "judge", "if", "a", "graph", "is", "legal", "or", "not", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L144-L152
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
transform
def transform(graph): '''core transform function for graph. ''' graphs = [] for _ in range(Constant.N_NEIGHBOURS * 2): random_num = randrange(3) temp_graph = None if random_num == 0: temp_graph = to_deeper_graph(deepcopy(graph)) elif random_num == 1: ...
python
def transform(graph): '''core transform function for graph. ''' graphs = [] for _ in range(Constant.N_NEIGHBOURS * 2): random_num = randrange(3) temp_graph = None if random_num == 0: temp_graph = to_deeper_graph(deepcopy(graph)) elif random_num == 1: ...
[ "def", "transform", "(", "graph", ")", ":", "graphs", "=", "[", "]", "for", "_", "in", "range", "(", "Constant", ".", "N_NEIGHBOURS", "*", "2", ")", ":", "random_num", "=", "randrange", "(", "3", ")", "temp_graph", "=", "None", "if", "random_num", "=...
core transform function for graph.
[ "core", "transform", "function", "for", "graph", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L155-L176
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
uniform
def uniform(low, high, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState ''' assert high > low, 'Upper bound must be larger than lower bound' return random_state.uniform(low, high)
python
def uniform(low, high, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState ''' assert high > low, 'Upper bound must be larger than lower bound' return random_state.uniform(low, high)
[ "def", "uniform", "(", "low", ",", "high", ",", "random_state", ")", ":", "assert", "high", ">", "low", ",", "'Upper bound must be larger than lower bound'", "return", "random_state", ".", "uniform", "(", "low", ",", "high", ")" ]
low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState
[ "low", ":", "an", "float", "that", "represent", "an", "lower", "bound", "high", ":", "an", "float", "that", "represent", "an", "upper", "bound", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomState" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L43-L50
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
quniform
def quniform(low, high, q, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(uniform(low, high, random_state) / q) * q
python
def quniform(low, high, q, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(uniform(low, high, random_state) / q) * q
[ "def", "quniform", "(", "low", ",", "high", ",", "q", ",", "random_state", ")", ":", "return", "np", ".", "round", "(", "uniform", "(", "low", ",", "high", ",", "random_state", ")", "/", "q", ")", "*", "q" ]
low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState
[ "low", ":", "an", "float", "that", "represent", "an", "lower", "bound", "high", ":", "an", "float", "that", "represent", "an", "upper", "bound", "q", ":", "sample", "step", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomSt...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L53-L60
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
loguniform
def loguniform(low, high, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState ''' assert low > 0, 'Lower bound must be positive' return np.exp(uniform(np.log(low), np.log(high), random...
python
def loguniform(low, high, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState ''' assert low > 0, 'Lower bound must be positive' return np.exp(uniform(np.log(low), np.log(high), random...
[ "def", "loguniform", "(", "low", ",", "high", ",", "random_state", ")", ":", "assert", "low", ">", "0", ",", "'Lower bound must be positive'", "return", "np", ".", "exp", "(", "uniform", "(", "np", ".", "log", "(", "low", ")", ",", "np", ".", "log", ...
low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState
[ "low", ":", "an", "float", "that", "represent", "an", "lower", "bound", "high", ":", "an", "float", "that", "represent", "an", "upper", "bound", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomState" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L63-L70
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
qloguniform
def qloguniform(low, high, q, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(loguniform(low, high, random_state) / q) * q
python
def qloguniform(low, high, q, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(loguniform(low, high, random_state) / q) * q
[ "def", "qloguniform", "(", "low", ",", "high", ",", "q", ",", "random_state", ")", ":", "return", "np", ".", "round", "(", "loguniform", "(", "low", ",", "high", ",", "random_state", ")", "/", "q", ")", "*", "q" ]
low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState
[ "low", ":", "an", "float", "that", "represent", "an", "lower", "bound", "high", ":", "an", "float", "that", "represent", "an", "upper", "bound", "q", ":", "sample", "step", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomSt...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L73-L80
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
qnormal
def qnormal(mu, sigma, q, random_state): ''' mu: float or array_like of floats sigma: float or array_like of floats q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(normal(mu, sigma, random_state) / q) * q
python
def qnormal(mu, sigma, q, random_state): ''' mu: float or array_like of floats sigma: float or array_like of floats q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(normal(mu, sigma, random_state) / q) * q
[ "def", "qnormal", "(", "mu", ",", "sigma", ",", "q", ",", "random_state", ")", ":", "return", "np", ".", "round", "(", "normal", "(", "mu", ",", "sigma", ",", "random_state", ")", "/", "q", ")", "*", "q" ]
mu: float or array_like of floats sigma: float or array_like of floats q: sample step random_state: an object of numpy.random.RandomState
[ "mu", ":", "float", "or", "array_like", "of", "floats", "sigma", ":", "float", "or", "array_like", "of", "floats", "q", ":", "sample", "step", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomState" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L96-L103
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
lognormal
def lognormal(mu, sigma, random_state): ''' mu: float or array_like of floats sigma: float or array_like of floats random_state: an object of numpy.random.RandomState ''' return np.exp(normal(mu, sigma, random_state))
python
def lognormal(mu, sigma, random_state): ''' mu: float or array_like of floats sigma: float or array_like of floats random_state: an object of numpy.random.RandomState ''' return np.exp(normal(mu, sigma, random_state))
[ "def", "lognormal", "(", "mu", ",", "sigma", ",", "random_state", ")", ":", "return", "np", ".", "exp", "(", "normal", "(", "mu", ",", "sigma", ",", "random_state", ")", ")" ]
mu: float or array_like of floats sigma: float or array_like of floats random_state: an object of numpy.random.RandomState
[ "mu", ":", "float", "or", "array_like", "of", "floats", "sigma", ":", "float", "or", "array_like", "of", "floats", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomState" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L106-L112
train
Microsoft/nni
src/sdk/pynni/nni/parameter_expressions.py
qlognormal
def qlognormal(mu, sigma, q, random_state): ''' mu: float or array_like of floats sigma: float or array_like of floats q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(lognormal(mu, sigma, random_state) / q) * q
python
def qlognormal(mu, sigma, q, random_state): ''' mu: float or array_like of floats sigma: float or array_like of floats q: sample step random_state: an object of numpy.random.RandomState ''' return np.round(lognormal(mu, sigma, random_state) / q) * q
[ "def", "qlognormal", "(", "mu", ",", "sigma", ",", "q", ",", "random_state", ")", ":", "return", "np", ".", "round", "(", "lognormal", "(", "mu", ",", "sigma", ",", "random_state", ")", "/", "q", ")", "*", "q" ]
mu: float or array_like of floats sigma: float or array_like of floats q: sample step random_state: an object of numpy.random.RandomState
[ "mu", ":", "float", "or", "array_like", "of", "floats", "sigma", ":", "float", "or", "array_like", "of", "floats", "q", ":", "sample", "step", "random_state", ":", "an", "object", "of", "numpy", ".", "random", ".", "RandomState" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/parameter_expressions.py#L115-L122
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/Prediction.py
predict
def predict(parameters_value, regressor_gp): ''' Predict by Gaussian Process Model ''' parameters_value = numpy.array(parameters_value).reshape(-1, len(parameters_value)) mu, sigma = regressor_gp.predict(parameters_value, return_std=True) return mu[0], sigma[0]
python
def predict(parameters_value, regressor_gp): ''' Predict by Gaussian Process Model ''' parameters_value = numpy.array(parameters_value).reshape(-1, len(parameters_value)) mu, sigma = regressor_gp.predict(parameters_value, return_std=True) return mu[0], sigma[0]
[ "def", "predict", "(", "parameters_value", ",", "regressor_gp", ")", ":", "parameters_value", "=", "numpy", ".", "array", "(", "parameters_value", ")", ".", "reshape", "(", "-", "1", ",", "len", "(", "parameters_value", ")", ")", "mu", ",", "sigma", "=", ...
Predict by Gaussian Process Model
[ "Predict", "by", "Gaussian", "Process", "Model" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/Prediction.py#L29-L36
train
Microsoft/nni
tools/nni_trial_tool/rest_utils.py
rest_get
def rest_get(url, timeout): '''Call rest get method''' try: response = requests.get(url, timeout=timeout) return response except Exception as e: print('Get exception {0} when sending http get to url {1}'.format(str(e), url)) return None
python
def rest_get(url, timeout): '''Call rest get method''' try: response = requests.get(url, timeout=timeout) return response except Exception as e: print('Get exception {0} when sending http get to url {1}'.format(str(e), url)) return None
[ "def", "rest_get", "(", "url", ",", "timeout", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "timeout", "=", "timeout", ")", "return", "response", "except", "Exception", "as", "e", ":", "print", "(", "'Get exception {0} ...
Call rest get method
[ "Call", "rest", "get", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/rest_utils.py#L25-L32
train
Microsoft/nni
tools/nni_trial_tool/rest_utils.py
rest_post
def rest_post(url, data, timeout, rethrow_exception=False): '''Call rest post method''' try: response = requests.post(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exceptio...
python
def rest_post(url, data, timeout, rethrow_exception=False): '''Call rest post method''' try: response = requests.post(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exceptio...
[ "def", "rest_post", "(", "url", ",", "data", ",", "timeout", ",", "rethrow_exception", "=", "False", ")", ":", "try", ":", "response", "=", "requests", ".", "post", "(", "url", ",", "headers", "=", "{", "'Accept'", ":", "'application/json'", ",", "'Conte...
Call rest post method
[ "Call", "rest", "post", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/rest_utils.py#L34-L44
train
Microsoft/nni
tools/nni_trial_tool/rest_utils.py
rest_put
def rest_put(url, data, timeout): '''Call rest put method''' try: response = requests.put(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exception as e: print('Get ex...
python
def rest_put(url, data, timeout): '''Call rest put method''' try: response = requests.put(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exception as e: print('Get ex...
[ "def", "rest_put", "(", "url", ",", "data", ",", "timeout", ")", ":", "try", ":", "response", "=", "requests", ".", "put", "(", "url", ",", "headers", "=", "{", "'Accept'", ":", "'application/json'", ",", "'Content-Type'", ":", "'application/json'", "}", ...
Call rest put method
[ "Call", "rest", "put", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/rest_utils.py#L46-L54
train
Microsoft/nni
tools/nni_trial_tool/rest_utils.py
rest_delete
def rest_delete(url, timeout): '''Call rest delete method''' try: response = requests.delete(url, timeout=timeout) return response except Exception as e: print('Get exception {0} when sending http delete to url {1}'.format(str(e), url)) return None
python
def rest_delete(url, timeout): '''Call rest delete method''' try: response = requests.delete(url, timeout=timeout) return response except Exception as e: print('Get exception {0} when sending http delete to url {1}'.format(str(e), url)) return None
[ "def", "rest_delete", "(", "url", ",", "timeout", ")", ":", "try", ":", "response", "=", "requests", ".", "delete", "(", "url", ",", "timeout", "=", "timeout", ")", "return", "response", "except", "Exception", "as", "e", ":", "print", "(", "'Get exceptio...
Call rest delete method
[ "Call", "rest", "delete", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/rest_utils.py#L56-L63
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefitting_assessor.py
CurvefittingAssessor.trial_end
def trial_end(self, trial_job_id, success): """update the best performance of completed trial job Parameters ---------- trial_job_id: int trial job id success: bool True if succssfully finish the experiment, False otherwise """ if ...
python
def trial_end(self, trial_job_id, success): """update the best performance of completed trial job Parameters ---------- trial_job_id: int trial job id success: bool True if succssfully finish the experiment, False otherwise """ if ...
[ "def", "trial_end", "(", "self", ",", "trial_job_id", ",", "success", ")", ":", "if", "success", ":", "if", "self", ".", "set_best_performance", ":", "self", ".", "completed_best_performance", "=", "max", "(", "self", ".", "completed_best_performance", ",", "s...
update the best performance of completed trial job Parameters ---------- trial_job_id: int trial job id success: bool True if succssfully finish the experiment, False otherwise
[ "update", "the", "best", "performance", "of", "completed", "trial", "job", "Parameters", "----------", "trial_job_id", ":", "int", "trial", "job", "id", "success", ":", "bool", "True", "if", "succssfully", "finish", "the", "experiment", "False", "otherwise" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefitting_assessor.py#L68-L86
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefitting_assessor.py
CurvefittingAssessor.assess_trial
def assess_trial(self, trial_job_id, trial_history): """assess whether a trial should be early stop by curve fitting algorithm Parameters ---------- trial_job_id: int trial job id trial_history: list The history performance matrix of each trial R...
python
def assess_trial(self, trial_job_id, trial_history): """assess whether a trial should be early stop by curve fitting algorithm Parameters ---------- trial_job_id: int trial job id trial_history: list The history performance matrix of each trial R...
[ "def", "assess_trial", "(", "self", ",", "trial_job_id", ",", "trial_history", ")", ":", "self", ".", "trial_job_id", "=", "trial_job_id", "self", ".", "trial_history", "=", "trial_history", "if", "not", "self", ".", "set_best_performance", ":", "return", "Asses...
assess whether a trial should be early stop by curve fitting algorithm Parameters ---------- trial_job_id: int trial job id trial_history: list The history performance matrix of each trial Returns ------- bool AssessResult.Goo...
[ "assess", "whether", "a", "trial", "should", "be", "early", "stop", "by", "curve", "fitting", "algorithm" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefitting_assessor.py#L88-L145
train
Microsoft/nni
src/sdk/pynni/nni/multi_phase/multi_phase_dispatcher.py
MultiPhaseMsgDispatcher.handle_initialize
def handle_initialize(self, data): ''' data is search space ''' self.tuner.update_search_space(data) send(CommandType.Initialized, '') return True
python
def handle_initialize(self, data): ''' data is search space ''' self.tuner.update_search_space(data) send(CommandType.Initialized, '') return True
[ "def", "handle_initialize", "(", "self", ",", "data", ")", ":", "self", ".", "tuner", ".", "update_search_space", "(", "data", ")", "send", "(", "CommandType", ".", "Initialized", ",", "''", ")", "return", "True" ]
data is search space
[ "data", "is", "search", "space" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/multi_phase/multi_phase_dispatcher.py#L94-L100
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.generate_parameters
def generate_parameters(self, parameter_id): """ Returns a set of trial neural architecture, as a serializable object. Parameters ---------- parameter_id : int """ if not self.history: self.init_search() new_father_id = None generated...
python
def generate_parameters(self, parameter_id): """ Returns a set of trial neural architecture, as a serializable object. Parameters ---------- parameter_id : int """ if not self.history: self.init_search() new_father_id = None generated...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ")", ":", "if", "not", "self", ".", "history", ":", "self", ".", "init_search", "(", ")", "new_father_id", "=", "None", "generated_graph", "=", "None", "if", "not", "self", ".", "training_queue"...
Returns a set of trial neural architecture, as a serializable object. Parameters ---------- parameter_id : int
[ "Returns", "a", "set", "of", "trial", "neural", "architecture", "as", "a", "serializable", "object", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L126-L153
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.receive_trial_result
def receive_trial_result(self, parameter_id, parameters, value): """ Record an observation of the objective function. Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key. """...
python
def receive_trial_result(self, parameter_id, parameters, value): """ Record an observation of the objective function. Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key. """...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ")", ":", "reward", "=", "extract_scalar_reward", "(", "value", ")", "if", "parameter_id", "not", "in", "self", ".", "total_data", ":", "raise", "RuntimeError", "...
Record an observation of the objective function. Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key.
[ "Record", "an", "observation", "of", "the", "objective", "function", ".", "Parameters", "----------", "parameter_id", ":", "int", "parameters", ":", "dict", "value", ":", "dict", "/", "float", "if", "value", "is", "dict", "it", "should", "have", "default", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L155-L176
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.init_search
def init_search(self): """Call the generators to generate the initial architectures for the search.""" if self.verbose: logger.info("Initializing search.") for generator in self.generators: graph = generator(self.n_classes, self.input_shape).generate( self...
python
def init_search(self): """Call the generators to generate the initial architectures for the search.""" if self.verbose: logger.info("Initializing search.") for generator in self.generators: graph = generator(self.n_classes, self.input_shape).generate( self...
[ "def", "init_search", "(", "self", ")", ":", "if", "self", ".", "verbose", ":", "logger", ".", "info", "(", "\"Initializing search.\"", ")", "for", "generator", "in", "self", ".", "generators", ":", "graph", "=", "generator", "(", "self", ".", "n_classes",...
Call the generators to generate the initial architectures for the search.
[ "Call", "the", "generators", "to", "generate", "the", "initial", "architectures", "for", "the", "search", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L178-L192
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.generate
def generate(self): """Generate the next neural architecture. Returns ------- other_info: any object Anything to be saved in the training queue together with the architecture. generated_graph: Graph An instance of Graph. """ generated_grap...
python
def generate(self): """Generate the next neural architecture. Returns ------- other_info: any object Anything to be saved in the training queue together with the architecture. generated_graph: Graph An instance of Graph. """ generated_grap...
[ "def", "generate", "(", "self", ")", ":", "generated_graph", ",", "new_father_id", "=", "self", ".", "bo", ".", "generate", "(", "self", ".", "descriptors", ")", "if", "new_father_id", "is", "None", ":", "new_father_id", "=", "0", "generated_graph", "=", "...
Generate the next neural architecture. Returns ------- other_info: any object Anything to be saved in the training queue together with the architecture. generated_graph: Graph An instance of Graph.
[ "Generate", "the", "next", "neural", "architecture", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L194-L211
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.update
def update(self, other_info, graph, metric_value, model_id): """ Update the controller with evaluation result of a neural architecture. Parameters ---------- other_info: any object In our case it is the father ID in the search tree. graph: Graph An instan...
python
def update(self, other_info, graph, metric_value, model_id): """ Update the controller with evaluation result of a neural architecture. Parameters ---------- other_info: any object In our case it is the father ID in the search tree. graph: Graph An instan...
[ "def", "update", "(", "self", ",", "other_info", ",", "graph", ",", "metric_value", ",", "model_id", ")", ":", "father_id", "=", "other_info", "self", ".", "bo", ".", "fit", "(", "[", "graph", ".", "extract_descriptor", "(", ")", "]", ",", "[", "metric...
Update the controller with evaluation result of a neural architecture. Parameters ---------- other_info: any object In our case it is the father ID in the search tree. graph: Graph An instance of Graph. The trained neural architecture. metric_value: float...
[ "Update", "the", "controller", "with", "evaluation", "result", "of", "a", "neural", "architecture", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L213-L228
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.add_model
def add_model(self, metric_value, model_id): """ Add model to the history, x_queue and y_queue Parameters ---------- metric_value : float graph : dict model_id : int Returns ------- model : dict """ if self.verbose: lo...
python
def add_model(self, metric_value, model_id): """ Add model to the history, x_queue and y_queue Parameters ---------- metric_value : float graph : dict model_id : int Returns ------- model : dict """ if self.verbose: lo...
[ "def", "add_model", "(", "self", ",", "metric_value", ",", "model_id", ")", ":", "if", "self", ".", "verbose", ":", "logger", ".", "info", "(", "\"Saving model.\"", ")", "# Update best_model text file", "ret", "=", "{", "\"model_id\"", ":", "model_id", ",", ...
Add model to the history, x_queue and y_queue Parameters ---------- metric_value : float graph : dict model_id : int Returns ------- model : dict
[ "Add", "model", "to", "the", "history", "x_queue", "and", "y_queue" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L230-L253
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.get_best_model_id
def get_best_model_id(self): """ Get the best model_id from history using the metric value """ if self.optimize_mode is OptimizeMode.Maximize: return max(self.history, key=lambda x: x["metric_value"])["model_id"] return min(self.history, key=lambda x: x["metric_value"])["mod...
python
def get_best_model_id(self): """ Get the best model_id from history using the metric value """ if self.optimize_mode is OptimizeMode.Maximize: return max(self.history, key=lambda x: x["metric_value"])["model_id"] return min(self.history, key=lambda x: x["metric_value"])["mod...
[ "def", "get_best_model_id", "(", "self", ")", ":", "if", "self", ".", "optimize_mode", "is", "OptimizeMode", ".", "Maximize", ":", "return", "max", "(", "self", ".", "history", ",", "key", "=", "lambda", "x", ":", "x", "[", "\"metric_value\"", "]", ")", ...
Get the best model_id from history using the metric value
[ "Get", "the", "best", "model_id", "from", "history", "using", "the", "metric", "value" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L255-L261
train
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py
NetworkMorphismTuner.load_model_by_id
def load_model_by_id(self, model_id): """Get the model by model_id Parameters ---------- model_id : int model index Returns ------- load_model : Graph the model graph representation """ with open(os.path.join(self...
python
def load_model_by_id(self, model_id): """Get the model by model_id Parameters ---------- model_id : int model index Returns ------- load_model : Graph the model graph representation """ with open(os.path.join(self...
[ "def", "load_model_by_id", "(", "self", ",", "model_id", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "str", "(", "model_id", ")", "+", "\".json\"", ")", ")", "as", "fin", ":", "json_str", "=", "fin"...
Get the model by model_id Parameters ---------- model_id : int model index Returns ------- load_model : Graph the model graph representation
[ "Get", "the", "model", "by", "model_id" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L263-L281
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
_rand_init
def _rand_init(x_bounds, x_types, selection_num_starting_points): ''' Random sample some init seed within bounds. ''' return [lib_data.rand(x_bounds, x_types) for i \ in range(0, selection_num_starting_points)]
python
def _rand_init(x_bounds, x_types, selection_num_starting_points): ''' Random sample some init seed within bounds. ''' return [lib_data.rand(x_bounds, x_types) for i \ in range(0, selection_num_starting_points)]
[ "def", "_rand_init", "(", "x_bounds", ",", "x_types", ",", "selection_num_starting_points", ")", ":", "return", "[", "lib_data", ".", "rand", "(", "x_bounds", ",", "x_types", ")", "for", "i", "in", "range", "(", "0", ",", "selection_num_starting_points", ")", ...
Random sample some init seed within bounds.
[ "Random", "sample", "some", "init", "seed", "within", "bounds", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L493-L498
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
get_median
def get_median(temp_list): """Return median """ num = len(temp_list) temp_list.sort() print(temp_list) if num % 2 == 0: median = (temp_list[int(num/2)] + temp_list[int(num/2) - 1]) / 2 else: median = temp_list[int(num/2)] return median
python
def get_median(temp_list): """Return median """ num = len(temp_list) temp_list.sort() print(temp_list) if num % 2 == 0: median = (temp_list[int(num/2)] + temp_list[int(num/2) - 1]) / 2 else: median = temp_list[int(num/2)] return median
[ "def", "get_median", "(", "temp_list", ")", ":", "num", "=", "len", "(", "temp_list", ")", "temp_list", ".", "sort", "(", ")", "print", "(", "temp_list", ")", "if", "num", "%", "2", "==", "0", ":", "median", "=", "(", "temp_list", "[", "int", "(", ...
Return median
[ "Return", "median" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L501-L511
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
MetisTuner.update_search_space
def update_search_space(self, search_space): """Update the self.x_bounds and self.x_types by the search_space.json Parameters ---------- search_space : dict """ self.x_bounds = [[] for i in range(len(search_space))] self.x_types = [NONE_TYPE for i in range(len(se...
python
def update_search_space(self, search_space): """Update the self.x_bounds and self.x_types by the search_space.json Parameters ---------- search_space : dict """ self.x_bounds = [[] for i in range(len(search_space))] self.x_types = [NONE_TYPE for i in range(len(se...
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "self", ".", "x_bounds", "=", "[", "[", "]", "for", "i", "in", "range", "(", "len", "(", "search_space", ")", ")", "]", "self", ".", "x_types", "=", "[", "NONE_TYPE", "for", "i...
Update the self.x_bounds and self.x_types by the search_space.json Parameters ---------- search_space : dict
[ "Update", "the", "self", ".", "x_bounds", "and", "self", ".", "x_types", "by", "the", "search_space", ".", "json" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L113-L164
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
MetisTuner._pack_output
def _pack_output(self, init_parameter): """Pack the output Parameters ---------- init_parameter : dict Returns ------- output : dict """ output = {} for i, param in enumerate(init_parameter): output[self.key_order[i]] = param ...
python
def _pack_output(self, init_parameter): """Pack the output Parameters ---------- init_parameter : dict Returns ------- output : dict """ output = {} for i, param in enumerate(init_parameter): output[self.key_order[i]] = param ...
[ "def", "_pack_output", "(", "self", ",", "init_parameter", ")", ":", "output", "=", "{", "}", "for", "i", ",", "param", "in", "enumerate", "(", "init_parameter", ")", ":", "output", "[", "self", ".", "key_order", "[", "i", "]", "]", "=", "param", "re...
Pack the output Parameters ---------- init_parameter : dict Returns ------- output : dict
[ "Pack", "the", "output" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L167-L181
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
MetisTuner.generate_parameters
def generate_parameters(self, parameter_id): """Generate next parameter for trial If the number of trial result is lower than cold start number, metis will first random generate some parameters. Otherwise, metis will choose the parameters by the Gussian Process Model and the Gussian Mixt...
python
def generate_parameters(self, parameter_id): """Generate next parameter for trial If the number of trial result is lower than cold start number, metis will first random generate some parameters. Otherwise, metis will choose the parameters by the Gussian Process Model and the Gussian Mixt...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ")", ":", "if", "len", "(", "self", ".", "samples_x", ")", "<", "self", ".", "cold_start_num", ":", "init_parameter", "=", "_rand_init", "(", "self", ".", "x_bounds", ",", "self", ".", "x_type...
Generate next parameter for trial If the number of trial result is lower than cold start number, metis will first random generate some parameters. Otherwise, metis will choose the parameters by the Gussian Process Model and the Gussian Mixture Model. Parameters ---------- ...
[ "Generate", "next", "parameter", "for", "trial", "If", "the", "number", "of", "trial", "result", "is", "lower", "than", "cold", "start", "number", "metis", "will", "first", "random", "generate", "some", "parameters", ".", "Otherwise", "metis", "will", "choose"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L184-L212
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
MetisTuner.receive_trial_result
def receive_trial_result(self, parameter_id, parameters, value): """Tuner receive result from trial. Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key. """ value = extr...
python
def receive_trial_result(self, parameter_id, parameters, value): """Tuner receive result from trial. Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key. """ value = extr...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ")", ":", "value", "=", "extract_scalar_reward", "(", "value", ")", "if", "self", ".", "optimize_mode", "==", "OptimizeMode", ".", "Maximize", ":", "value", "=", ...
Tuner receive result from trial. Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key.
[ "Tuner", "receive", "result", "from", "trial", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L215-L255
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
MetisTuner.import_data
def 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' """ _completed_num = 0 for trial_info in data: logger.info("Im...
python
def 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' """ _completed_num = 0 for trial_info in data: logger.info("Im...
[ "def", "import_data", "(", "self", ",", "data", ")", ":", "_completed_num", "=", "0", "for", "trial_info", "in", "data", ":", "logger", ".", "info", "(", "\"Importing data, current processing progress %s / %s\"", "%", "(", "_completed_num", ",", "len", "(", "dat...
Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value'
[ "Import", "additional", "data", "for", "tuning", "Parameters", "----------", "data", ":", "a", "list", "of", "dictionarys", "each", "of", "which", "has", "at", "least", "two", "keys", "parameter", "and", "value" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/metis_tuner.py#L405-L427
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/CreateModel.py
create_model
def create_model(samples_x, samples_y_aggregation, n_restarts_optimizer=250, is_white_kernel=False): ''' Trains GP regression model ''' kernel = gp.kernels.ConstantKernel(constant_value=1, constant_value_bounds=(1e-12, 1e12)) * \ ...
python
def create_model(samples_x, samples_y_aggregation, n_restarts_optimizer=250, is_white_kernel=False): ''' Trains GP regression model ''' kernel = gp.kernels.ConstantKernel(constant_value=1, constant_value_bounds=(1e-12, 1e12)) * \ ...
[ "def", "create_model", "(", "samples_x", ",", "samples_y_aggregation", ",", "n_restarts_optimizer", "=", "250", ",", "is_white_kernel", "=", "False", ")", ":", "kernel", "=", "gp", ".", "kernels", ".", "ConstantKernel", "(", "constant_value", "=", "1", ",", "c...
Trains GP regression model
[ "Trains", "GP", "regression", "model" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/CreateModel.py#L30-L52
train
Microsoft/nni
src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py
GridSearchTuner.json2paramater
def json2paramater(self, ss_spec): ''' generate all possible configs for hyperparameters from hyperparameter space. ss_spec: hyperparameter space ''' if isinstance(ss_spec, dict): if '_type' in ss_spec.keys(): _type = ss_spec['_type'] _...
python
def json2paramater(self, ss_spec): ''' generate all possible configs for hyperparameters from hyperparameter space. ss_spec: hyperparameter space ''' if isinstance(ss_spec, dict): if '_type' in ss_spec.keys(): _type = ss_spec['_type'] _...
[ "def", "json2paramater", "(", "self", ",", "ss_spec", ")", ":", "if", "isinstance", "(", "ss_spec", ",", "dict", ")", ":", "if", "'_type'", "in", "ss_spec", ".", "keys", "(", ")", ":", "_type", "=", "ss_spec", "[", "'_type'", "]", "_value", "=", "ss_...
generate all possible configs for hyperparameters from hyperparameter space. ss_spec: hyperparameter space
[ "generate", "all", "possible", "configs", "for", "hyperparameters", "from", "hyperparameter", "space", ".", "ss_spec", ":", "hyperparameter", "space" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py#L59-L94
train
Microsoft/nni
src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py
GridSearchTuner._parse_quniform
def _parse_quniform(self, param_value): '''parse type of quniform parameter and return a list''' if param_value[2] < 2: raise RuntimeError("The number of values sampled (q) should be at least 2") low, high, count = param_value[0], param_value[1], param_value[2] interval = (hi...
python
def _parse_quniform(self, param_value): '''parse type of quniform parameter and return a list''' if param_value[2] < 2: raise RuntimeError("The number of values sampled (q) should be at least 2") low, high, count = param_value[0], param_value[1], param_value[2] interval = (hi...
[ "def", "_parse_quniform", "(", "self", ",", "param_value", ")", ":", "if", "param_value", "[", "2", "]", "<", "2", ":", "raise", "RuntimeError", "(", "\"The number of values sampled (q) should be at least 2\"", ")", "low", ",", "high", ",", "count", "=", "param_...
parse type of quniform parameter and return a list
[ "parse", "type", "of", "quniform", "parameter", "and", "return", "a", "list" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py#L96-L102
train
Microsoft/nni
src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py
GridSearchTuner.parse_qtype
def parse_qtype(self, param_type, param_value): '''parse type of quniform or qloguniform''' if param_type == 'quniform': return self._parse_quniform(param_value) if param_type == 'qloguniform': param_value[:2] = np.log(param_value[:2]) return list(np.exp(self....
python
def parse_qtype(self, param_type, param_value): '''parse type of quniform or qloguniform''' if param_type == 'quniform': return self._parse_quniform(param_value) if param_type == 'qloguniform': param_value[:2] = np.log(param_value[:2]) return list(np.exp(self....
[ "def", "parse_qtype", "(", "self", ",", "param_type", ",", "param_value", ")", ":", "if", "param_type", "==", "'quniform'", ":", "return", "self", ".", "_parse_quniform", "(", "param_value", ")", "if", "param_type", "==", "'qloguniform'", ":", "param_value", "...
parse type of quniform or qloguniform
[ "parse", "type", "of", "quniform", "or", "qloguniform" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py#L104-L112
train
Microsoft/nni
src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py
GridSearchTuner.expand_parameters
def expand_parameters(self, para): ''' Enumerate all possible combinations of all parameters para: {key1: [v11, v12, ...], key2: [v21, v22, ...], ...} return: {{key1: v11, key2: v21, ...}, {key1: v11, key2: v22, ...}, ...} ''' if len(para) == 1: for key, value...
python
def expand_parameters(self, para): ''' Enumerate all possible combinations of all parameters para: {key1: [v11, v12, ...], key2: [v21, v22, ...], ...} return: {{key1: v11, key2: v21, ...}, {key1: v11, key2: v22, ...}, ...} ''' if len(para) == 1: for key, value...
[ "def", "expand_parameters", "(", "self", ",", "para", ")", ":", "if", "len", "(", "para", ")", "==", "1", ":", "for", "key", ",", "values", "in", "para", ".", "items", "(", ")", ":", "return", "list", "(", "map", "(", "lambda", "v", ":", "{", "...
Enumerate all possible combinations of all parameters para: {key1: [v11, v12, ...], key2: [v21, v22, ...], ...} return: {{key1: v11, key2: v21, ...}, {key1: v11, key2: v22, ...}, ...}
[ "Enumerate", "all", "possible", "combinations", "of", "all", "parameters", "para", ":", "{", "key1", ":", "[", "v11", "v12", "...", "]", "key2", ":", "[", "v21", "v22", "...", "]", "...", "}", "return", ":", "{{", "key1", ":", "v11", "key2", ":", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py#L114-L132
train
Microsoft/nni
src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py
GridSearchTuner.import_data
def 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' """ _completed_num = 0 for trial_info in data: logger.info("I...
python
def 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' """ _completed_num = 0 for trial_info in data: logger.info("I...
[ "def", "import_data", "(", "self", ",", "data", ")", ":", "_completed_num", "=", "0", "for", "trial_info", "in", "data", ":", "logger", ".", "info", "(", "\"Importing data, current processing progress %s / %s\"", "%", "(", "_completed_num", ",", "len", "(", "dat...
Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value'
[ "Import", "additional", "data", "for", "tuning" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/gridsearch_tuner/gridsearch_tuner.py#L153-L174
train
Microsoft/nni
tools/nni_trial_tool/log_utils.py
nni_log
def nni_log(log_type, log_message): '''Log message into stdout''' dt = datetime.now() print('[{0}] {1} {2}'.format(dt, log_type.value, log_message))
python
def nni_log(log_type, log_message): '''Log message into stdout''' dt = datetime.now() print('[{0}] {1} {2}'.format(dt, log_type.value, log_message))
[ "def", "nni_log", "(", "log_type", ",", "log_message", ")", ":", "dt", "=", "datetime", ".", "now", "(", ")", "print", "(", "'[{0}] {1} {2}'", ".", "format", "(", "dt", ",", "log_type", ".", "value", ",", "log_message", ")", ")" ]
Log message into stdout
[ "Log", "message", "into", "stdout" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/log_utils.py#L54-L57
train
Microsoft/nni
tools/nni_trial_tool/log_utils.py
RemoteLogger.write
def write(self, buf): ''' Write buffer data into logger/stdout ''' for line in buf.rstrip().splitlines(): self.orig_stdout.write(line.rstrip() + '\n') self.orig_stdout.flush() try: self.logger.log(self.log_level, line.rstrip()) ...
python
def write(self, buf): ''' Write buffer data into logger/stdout ''' for line in buf.rstrip().splitlines(): self.orig_stdout.write(line.rstrip() + '\n') self.orig_stdout.flush() try: self.logger.log(self.log_level, line.rstrip()) ...
[ "def", "write", "(", "self", ",", "buf", ")", ":", "for", "line", "in", "buf", ".", "rstrip", "(", ")", ".", "splitlines", "(", ")", ":", "self", ".", "orig_stdout", ".", "write", "(", "line", ".", "rstrip", "(", ")", "+", "'\\n'", ")", "self", ...
Write buffer data into logger/stdout
[ "Write", "buffer", "data", "into", "logger", "/", "stdout" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/log_utils.py#L106-L116
train
Microsoft/nni
tools/nni_trial_tool/log_utils.py
PipeLogReader.run
def run(self): """Run the thread, logging everything. If the log_collection is 'none', the log content will not be enqueued """ for line in iter(self.pipeReader.readline, ''): self.orig_stdout.write(line.rstrip() + '\n') self.orig_stdout.flush() if ...
python
def run(self): """Run the thread, logging everything. If the log_collection is 'none', the log content will not be enqueued """ for line in iter(self.pipeReader.readline, ''): self.orig_stdout.write(line.rstrip() + '\n') self.orig_stdout.flush() if ...
[ "def", "run", "(", "self", ")", ":", "for", "line", "in", "iter", "(", "self", ".", "pipeReader", ".", "readline", ",", "''", ")", ":", "self", ".", "orig_stdout", ".", "write", "(", "line", ".", "rstrip", "(", ")", "+", "'\\n'", ")", "self", "."...
Run the thread, logging everything. If the log_collection is 'none', the log content will not be enqueued
[ "Run", "the", "thread", "logging", "everything", ".", "If", "the", "log_collection", "is", "none", "the", "log", "content", "will", "not", "be", "enqueued" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/log_utils.py#L168-L181
train
Microsoft/nni
src/sdk/pynni/nni/utils.py
extract_scalar_reward
def extract_scalar_reward(value, scalar_key='default'): """ Extract scalar reward from trial result. Raises ------ RuntimeError Incorrect final result: the final result should be float/int, or a dict which has a key named "default" whose value is float/int. """ if isinstance...
python
def extract_scalar_reward(value, scalar_key='default'): """ Extract scalar reward from trial result. Raises ------ RuntimeError Incorrect final result: the final result should be float/int, or a dict which has a key named "default" whose value is float/int. """ if isinstance...
[ "def", "extract_scalar_reward", "(", "value", ",", "scalar_key", "=", "'default'", ")", ":", "if", "isinstance", "(", "value", ",", "float", ")", "or", "isinstance", "(", "value", ",", "int", ")", ":", "reward", "=", "value", "elif", "isinstance", "(", "...
Extract scalar reward from trial result. Raises ------ RuntimeError Incorrect final result: the final result should be float/int, or a dict which has a key named "default" whose value is float/int.
[ "Extract", "scalar", "reward", "from", "trial", "result", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/utils.py#L25-L41
train
Microsoft/nni
src/sdk/pynni/nni/utils.py
convert_dict2tuple
def convert_dict2tuple(value): """ convert dict type to tuple to solve unhashable problem. """ if isinstance(value, dict): for _keys in value: value[_keys] = convert_dict2tuple(value[_keys]) return tuple(sorted(value.items())) else: return value
python
def convert_dict2tuple(value): """ convert dict type to tuple to solve unhashable problem. """ if isinstance(value, dict): for _keys in value: value[_keys] = convert_dict2tuple(value[_keys]) return tuple(sorted(value.items())) else: return value
[ "def", "convert_dict2tuple", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "for", "_keys", "in", "value", ":", "value", "[", "_keys", "]", "=", "convert_dict2tuple", "(", "value", "[", "_keys", "]", ")", "return", "tu...
convert dict type to tuple to solve unhashable problem.
[ "convert", "dict", "type", "to", "tuple", "to", "solve", "unhashable", "problem", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/utils.py#L43-L52
train
Microsoft/nni
src/sdk/pynni/nni/utils.py
init_dispatcher_logger
def init_dispatcher_logger(): """ Initialize dispatcher logging configuration""" logger_file_path = 'dispatcher.log' if dispatcher_env_vars.NNI_LOG_DIRECTORY is not None: logger_file_path = os.path.join(dispatcher_env_vars.NNI_LOG_DIRECTORY, logger_file_path) init_logger(logger_file_path, dispat...
python
def init_dispatcher_logger(): """ Initialize dispatcher logging configuration""" logger_file_path = 'dispatcher.log' if dispatcher_env_vars.NNI_LOG_DIRECTORY is not None: logger_file_path = os.path.join(dispatcher_env_vars.NNI_LOG_DIRECTORY, logger_file_path) init_logger(logger_file_path, dispat...
[ "def", "init_dispatcher_logger", "(", ")", ":", "logger_file_path", "=", "'dispatcher.log'", "if", "dispatcher_env_vars", ".", "NNI_LOG_DIRECTORY", "is", "not", "None", ":", "logger_file_path", "=", "os", ".", "path", ".", "join", "(", "dispatcher_env_vars", ".", ...
Initialize dispatcher logging configuration
[ "Initialize", "dispatcher", "logging", "configuration" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/utils.py#L54-L59
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/config_generator.py
CG_BOHB.sample_from_largest_budget
def sample_from_largest_budget(self, info_dict): """We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" ...
python
def sample_from_largest_budget(self, info_dict): """We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" ...
[ "def", "sample_from_largest_budget", "(", "self", ",", "info_dict", ")", ":", "best", "=", "np", ".", "inf", "best_vector", "=", "None", "budget", "=", "max", "(", "self", ".", "kde_models", ".", "keys", "(", ")", ")", "l", "=", "self", ".", "kde_model...
We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" configurations, then prefer one with the largest l(x...
[ "We", "opted", "for", "a", "single", "multidimensional", "KDE", "compared", "to", "the", "hierarchy", "of", "one", "-", "dimensional", "KDEs", "used", "in", "TPE", ".", "The", "dimensional", "is", "seperated", "by", "budget", ".", "This", "function", "sample...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/config_generator.py#L114-L205
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/config_generator.py
CG_BOHB.get_config
def get_config(self, budget): """Function to sample a new configuration This function is called inside BOHB to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled Returns ------- ...
python
def get_config(self, budget): """Function to sample a new configuration This function is called inside BOHB to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled Returns ------- ...
[ "def", "get_config", "(", "self", ",", "budget", ")", ":", "logger", ".", "debug", "(", "'start sampling a new configuration.'", ")", "sample", "=", "None", "info_dict", "=", "{", "}", "# If no model is available, sample from prior", "# also mix in a fraction of random co...
Function to sample a new configuration This function is called inside BOHB to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled Returns ------- config return a valid confi...
[ "Function", "to", "sample", "a", "new", "configuration", "This", "function", "is", "called", "inside", "BOHB", "to", "query", "a", "new", "configuration" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/config_generator.py#L207-L241
train
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/config_generator.py
CG_BOHB.new_result
def new_result(self, loss, budget, parameters, update_model=True): """ Function to register finished runs. Every time a run has finished, this function should be called to register it with the loss. Parameters: ----------- loss: float the loss of the paramete...
python
def new_result(self, loss, budget, parameters, update_model=True): """ Function to register finished runs. Every time a run has finished, this function should be called to register it with the loss. Parameters: ----------- loss: float the loss of the paramete...
[ "def", "new_result", "(", "self", ",", "loss", ",", "budget", ",", "parameters", ",", "update_model", "=", "True", ")", ":", "if", "loss", "is", "None", ":", "# One could skip crashed results, but we decided", "# assign a +inf loss and count them as bad configurations", ...
Function to register finished runs. Every time a run has finished, this function should be called to register it with the loss. Parameters: ----------- loss: float the loss of the parameters budget: float the budget of the parameters parameters: d...
[ "Function", "to", "register", "finished", "runs", ".", "Every", "time", "a", "run", "has", "finished", "this", "function", "should", "be", "called", "to", "register", "it", "with", "the", "loss", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/config_generator.py#L266-L349
train
Microsoft/nni
src/sdk/pynni/nni/batch_tuner/batch_tuner.py
BatchTuner.is_valid
def is_valid(self, search_space): """ Check the search space is valid: only contains 'choice' type Parameters ---------- search_space : dict """ if not len(search_space) == 1: raise RuntimeError('BatchTuner only supprt one combined-paramreters...
python
def is_valid(self, search_space): """ Check the search space is valid: only contains 'choice' type Parameters ---------- search_space : dict """ if not len(search_space) == 1: raise RuntimeError('BatchTuner only supprt one combined-paramreters...
[ "def", "is_valid", "(", "self", ",", "search_space", ")", ":", "if", "not", "len", "(", "search_space", ")", "==", "1", ":", "raise", "RuntimeError", "(", "'BatchTuner only supprt one combined-paramreters key.'", ")", "for", "param", "in", "search_space", ":", "...
Check the search space is valid: only contains 'choice' type Parameters ---------- search_space : dict
[ "Check", "the", "search", "space", "is", "valid", ":", "only", "contains", "choice", "type", "Parameters", "----------", "search_space", ":", "dict" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/batch_tuner/batch_tuner.py#L54-L73
train
Microsoft/nni
src/sdk/pynni/nni/batch_tuner/batch_tuner.py
BatchTuner.generate_parameters
def generate_parameters(self, parameter_id): """Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int """ self.count +=1 if self.count>len(self.values)-1: raise nni.NoMoreTrialError('no more par...
python
def generate_parameters(self, parameter_id): """Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int """ self.count +=1 if self.count>len(self.values)-1: raise nni.NoMoreTrialError('no more par...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ")", ":", "self", ".", "count", "+=", "1", "if", "self", ".", "count", ">", "len", "(", "self", ".", "values", ")", "-", "1", ":", "raise", "nni", ".", "NoMoreTrialError", "(", "'no more p...
Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int
[ "Returns", "a", "dict", "of", "trial", "(", "hyper", "-", ")", "parameters", "as", "a", "serializable", "object", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/batch_tuner/batch_tuner.py#L84-L94
train
Microsoft/nni
examples/trials/weight_sharing/ga_squad/graph_to_tf.py
normalize
def normalize(inputs, epsilon=1e-8, scope="ln"): '''Applies layer normalization. Args: inputs: A tensor with 2 or more dimensions, where the first dimension has `batch_size`. epsilon: A floating number. A very small number for preventing ZeroDivision Error. ...
python
def normalize(inputs, epsilon=1e-8, scope="ln"): '''Applies layer normalization. Args: inputs: A tensor with 2 or more dimensions, where the first dimension has `batch_size`. epsilon: A floating number. A very small number for preventing ZeroDivision Error. ...
[ "def", "normalize", "(", "inputs", ",", "epsilon", "=", "1e-8", ",", "scope", "=", "\"ln\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ")", ":", "inputs_shape", "=", "inputs", ".", "get_shape", "(", ")", "params_shape", "=", "inputs_sh...
Applies layer normalization. Args: inputs: A tensor with 2 or more dimensions, where the first dimension has `batch_size`. epsilon: A floating number. A very small number for preventing ZeroDivision Error. scope: Optional scope for `variable_scope`. reuse: Boolean, whether to reuse ...
[ "Applies", "layer", "normalization", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/graph_to_tf.py#L28-L54
train
Microsoft/nni
examples/trials/weight_sharing/ga_squad/graph_to_tf.py
multihead_attention
def multihead_attention(queries, keys, scope="multihead_attention", num_units=None, num_heads=4, dropout_rate=0, is_training=True, causality=False): ...
python
def multihead_attention(queries, keys, scope="multihead_attention", num_units=None, num_heads=4, dropout_rate=0, is_training=True, causality=False): ...
[ "def", "multihead_attention", "(", "queries", ",", "keys", ",", "scope", "=", "\"multihead_attention\"", ",", "num_units", "=", "None", ",", "num_heads", "=", "4", ",", "dropout_rate", "=", "0", ",", "is_training", "=", "True", ",", "causality", "=", "False"...
Applies multihead attention. Args: queries: A 3d tensor with shape of [N, T_q, C_q]. keys: A 3d tensor with shape of [N, T_k, C_k]. num_units: A cdscalar. Attention size. dropout_rate: A floating point number. is_training: Boolean. Controller of mechanism for dropout. causality:...
[ "Applies", "multihead", "attention", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/graph_to_tf.py#L57-L164
train
Microsoft/nni
examples/trials/weight_sharing/ga_squad/graph_to_tf.py
positional_encoding
def positional_encoding(inputs, num_units=None, zero_pad=True, scale=True, scope="positional_encoding", reuse=None): ''' Return positinal embedding. ''' Shape = tf.shape(inputs) N ...
python
def positional_encoding(inputs, num_units=None, zero_pad=True, scale=True, scope="positional_encoding", reuse=None): ''' Return positinal embedding. ''' Shape = tf.shape(inputs) N ...
[ "def", "positional_encoding", "(", "inputs", ",", "num_units", "=", "None", ",", "zero_pad", "=", "True", ",", "scale", "=", "True", ",", "scope", "=", "\"positional_encoding\"", ",", "reuse", "=", "None", ")", ":", "Shape", "=", "tf", ".", "shape", "(",...
Return positinal embedding.
[ "Return", "positinal", "embedding", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/graph_to_tf.py#L167-L205
train
Microsoft/nni
examples/trials/weight_sharing/ga_squad/graph_to_tf.py
feedforward
def feedforward(inputs, num_units, scope="multihead_attention"): '''Point-wise feed forward net. Args: inputs: A 3d tensor with shape of [N, T, C]. num_units: A list of two integers. scope: Optional scope for `variable_scope`. reuse: Boolean, whether to r...
python
def feedforward(inputs, num_units, scope="multihead_attention"): '''Point-wise feed forward net. Args: inputs: A 3d tensor with shape of [N, T, C]. num_units: A list of two integers. scope: Optional scope for `variable_scope`. reuse: Boolean, whether to r...
[ "def", "feedforward", "(", "inputs", ",", "num_units", ",", "scope", "=", "\"multihead_attention\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ")", ":", "# Inner layer", "params", "=", "{", "\"inputs\"", ":", "inputs", ",", "\"filters\"", ...
Point-wise feed forward net. Args: inputs: A 3d tensor with shape of [N, T, C]. num_units: A list of two integers. scope: Optional scope for `variable_scope`. reuse: Boolean, whether to reuse the weights of a previous layer by the same name. Returns: A 3d tensor with the ...
[ "Point", "-", "wise", "feed", "forward", "net", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/graph_to_tf.py#L208-L240
train
Microsoft/nni
tools/nni_annotation/search_space_generator.py
generate
def generate(module_name, code): """Generate search space. Return a serializable search space object. module_name: name of the module (str) code: user code (str) """ try: ast_tree = ast.parse(code) except Exception: raise RuntimeError('Bad Python code') visitor = SearchS...
python
def generate(module_name, code): """Generate search space. Return a serializable search space object. module_name: name of the module (str) code: user code (str) """ try: ast_tree = ast.parse(code) except Exception: raise RuntimeError('Bad Python code') visitor = SearchS...
[ "def", "generate", "(", "module_name", ",", "code", ")", ":", "try", ":", "ast_tree", "=", "ast", ".", "parse", "(", "code", ")", "except", "Exception", ":", "raise", "RuntimeError", "(", "'Bad Python code'", ")", "visitor", "=", "SearchSpaceGenerator", "(",...
Generate search space. Return a serializable search space object. module_name: name of the module (str) code: user code (str)
[ "Generate", "search", "space", ".", "Return", "a", "serializable", "search", "space", "object", ".", "module_name", ":", "name", "of", "the", "module", "(", "str", ")", "code", ":", "user", "code", "(", "str", ")" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/search_space_generator.py#L114-L130
train
Microsoft/nni
tools/nni_cmd/rest_utils.py
rest_put
def rest_put(url, data, timeout, show_error=False): '''Call rest put method''' try: response = requests.put(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exception as except...
python
def rest_put(url, data, timeout, show_error=False): '''Call rest put method''' try: response = requests.put(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exception as except...
[ "def", "rest_put", "(", "url", ",", "data", ",", "timeout", ",", "show_error", "=", "False", ")", ":", "try", ":", "response", "=", "requests", ".", "put", "(", "url", ",", "headers", "=", "{", "'Accept'", ":", "'application/json'", ",", "'Content-Type'"...
Call rest put method
[ "Call", "rest", "put", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/rest_utils.py#L28-L37
train
Microsoft/nni
tools/nni_cmd/rest_utils.py
rest_post
def rest_post(url, data, timeout, show_error=False): '''Call rest post method''' try: response = requests.post(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exception as ex...
python
def rest_post(url, data, timeout, show_error=False): '''Call rest post method''' try: response = requests.post(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\ data=data, timeout=timeout) return response except Exception as ex...
[ "def", "rest_post", "(", "url", ",", "data", ",", "timeout", ",", "show_error", "=", "False", ")", ":", "try", ":", "response", "=", "requests", ".", "post", "(", "url", ",", "headers", "=", "{", "'Accept'", ":", "'application/json'", ",", "'Content-Type...
Call rest post method
[ "Call", "rest", "post", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/rest_utils.py#L39-L48
train
Microsoft/nni
tools/nni_cmd/rest_utils.py
rest_get
def rest_get(url, timeout, show_error=False): '''Call rest get method''' try: response = requests.get(url, timeout=timeout) return response except Exception as exception: if show_error: print_error(exception) return None
python
def rest_get(url, timeout, show_error=False): '''Call rest get method''' try: response = requests.get(url, timeout=timeout) return response except Exception as exception: if show_error: print_error(exception) return None
[ "def", "rest_get", "(", "url", ",", "timeout", ",", "show_error", "=", "False", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "timeout", "=", "timeout", ")", "return", "response", "except", "Exception", "as", "exception"...
Call rest get method
[ "Call", "rest", "get", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/rest_utils.py#L50-L58
train
Microsoft/nni
tools/nni_cmd/rest_utils.py
rest_delete
def rest_delete(url, timeout, show_error=False): '''Call rest delete method''' try: response = requests.delete(url, timeout=timeout) return response except Exception as exception: if show_error: print_error(exception) return None
python
def rest_delete(url, timeout, show_error=False): '''Call rest delete method''' try: response = requests.delete(url, timeout=timeout) return response except Exception as exception: if show_error: print_error(exception) return None
[ "def", "rest_delete", "(", "url", ",", "timeout", ",", "show_error", "=", "False", ")", ":", "try", ":", "response", "=", "requests", ".", "delete", "(", "url", ",", "timeout", "=", "timeout", ")", "return", "response", "except", "Exception", "as", "exce...
Call rest delete method
[ "Call", "rest", "delete", "method" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/rest_utils.py#L60-L68
train
Microsoft/nni
tools/nni_cmd/rest_utils.py
check_rest_server
def check_rest_server(rest_port): '''Check if restful server is ready''' retry_count = 5 for _ in range(retry_count): response = rest_get(check_status_url(rest_port), REST_TIME_OUT) if response: if response.status_code == 200: return True, response els...
python
def check_rest_server(rest_port): '''Check if restful server is ready''' retry_count = 5 for _ in range(retry_count): response = rest_get(check_status_url(rest_port), REST_TIME_OUT) if response: if response.status_code == 200: return True, response els...
[ "def", "check_rest_server", "(", "rest_port", ")", ":", "retry_count", "=", "5", "for", "_", "in", "range", "(", "retry_count", ")", ":", "response", "=", "rest_get", "(", "check_status_url", "(", "rest_port", ")", ",", "REST_TIME_OUT", ")", "if", "response"...
Check if restful server is ready
[ "Check", "if", "restful", "server", "is", "ready" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/rest_utils.py#L70-L82
train
Microsoft/nni
tools/nni_cmd/rest_utils.py
check_rest_server_quick
def check_rest_server_quick(rest_port): '''Check if restful server is ready, only check once''' response = rest_get(check_status_url(rest_port), 5) if response and response.status_code == 200: return True, response return False, None
python
def check_rest_server_quick(rest_port): '''Check if restful server is ready, only check once''' response = rest_get(check_status_url(rest_port), 5) if response and response.status_code == 200: return True, response return False, None
[ "def", "check_rest_server_quick", "(", "rest_port", ")", ":", "response", "=", "rest_get", "(", "check_status_url", "(", "rest_port", ")", ",", "5", ")", "if", "response", "and", "response", ".", "status_code", "==", "200", ":", "return", "True", ",", "respo...
Check if restful server is ready, only check once
[ "Check", "if", "restful", "server", "is", "ready", "only", "check", "once" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/rest_utils.py#L84-L89
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
vap
def vap(x, a, b, c): """Vapor pressure model Parameters ---------- x: int a: float b: float c: float Returns ------- float np.exp(a+b/x+c*np.log(x)) """ return np.exp(a+b/x+c*np.log(x))
python
def vap(x, a, b, c): """Vapor pressure model Parameters ---------- x: int a: float b: float c: float Returns ------- float np.exp(a+b/x+c*np.log(x)) """ return np.exp(a+b/x+c*np.log(x))
[ "def", "vap", "(", "x", ",", "a", ",", "b", ",", "c", ")", ":", "return", "np", ".", "exp", "(", "a", "+", "b", "/", "x", "+", "c", "*", "np", ".", "log", "(", "x", ")", ")" ]
Vapor pressure model Parameters ---------- x: int a: float b: float c: float Returns ------- float np.exp(a+b/x+c*np.log(x))
[ "Vapor", "pressure", "model", "Parameters", "----------", "x", ":", "int", "a", ":", "float", "b", ":", "float", "c", ":", "float" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L27-L42
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
logx_linear
def logx_linear(x, a, b): """logx linear Parameters ---------- x: int a: float b: float Returns ------- float a * np.log(x) + b """ x = np.log(x) return a*x + b
python
def logx_linear(x, a, b): """logx linear Parameters ---------- x: int a: float b: float Returns ------- float a * np.log(x) + b """ x = np.log(x) return a*x + b
[ "def", "logx_linear", "(", "x", ",", "a", ",", "b", ")", ":", "x", "=", "np", ".", "log", "(", "x", ")", "return", "a", "*", "x", "+", "b" ]
logx linear Parameters ---------- x: int a: float b: float Returns ------- float a * np.log(x) + b
[ "logx", "linear" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L89-L104
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
dr_hill_zero_background
def dr_hill_zero_background(x, theta, eta, kappa): """dr hill zero background Parameters ---------- x: int theta: float eta: float kappa: float Returns ------- float (theta* x**eta) / (kappa**eta + x**eta) """ return (theta* x**eta) / (kappa**eta + x**eta)
python
def dr_hill_zero_background(x, theta, eta, kappa): """dr hill zero background Parameters ---------- x: int theta: float eta: float kappa: float Returns ------- float (theta* x**eta) / (kappa**eta + x**eta) """ return (theta* x**eta) / (kappa**eta + x**eta)
[ "def", "dr_hill_zero_background", "(", "x", ",", "theta", ",", "eta", ",", "kappa", ")", ":", "return", "(", "theta", "*", "x", "**", "eta", ")", "/", "(", "kappa", "**", "eta", "+", "x", "**", "eta", ")" ]
dr hill zero background Parameters ---------- x: int theta: float eta: float kappa: float Returns ------- float (theta* x**eta) / (kappa**eta + x**eta)
[ "dr", "hill", "zero", "background", "Parameters", "----------", "x", ":", "int", "theta", ":", "float", "eta", ":", "float", "kappa", ":", "float" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L110-L125
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
log_power
def log_power(x, a, b, c): """"logistic power Parameters ---------- x: int a: float b: float c: float Returns ------- float a/(1.+(x/np.exp(b))**c) """ return a/(1.+(x/np.exp(b))**c)
python
def log_power(x, a, b, c): """"logistic power Parameters ---------- x: int a: float b: float c: float Returns ------- float a/(1.+(x/np.exp(b))**c) """ return a/(1.+(x/np.exp(b))**c)
[ "def", "log_power", "(", "x", ",", "a", ",", "b", ",", "c", ")", ":", "return", "a", "/", "(", "1.", "+", "(", "x", "/", "np", ".", "exp", "(", "b", ")", ")", "**", "c", ")" ]
logistic power Parameters ---------- x: int a: float b: float c: float Returns ------- float a/(1.+(x/np.exp(b))**c)
[ "logistic", "power" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L131-L146
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
pow4
def pow4(x, alpha, a, b, c): """pow4 Parameters ---------- x: int alpha: float a: float b: float c: float Returns ------- float c - (a*x+b)**-alpha """ return c - (a*x+b)**-alpha
python
def pow4(x, alpha, a, b, c): """pow4 Parameters ---------- x: int alpha: float a: float b: float c: float Returns ------- float c - (a*x+b)**-alpha """ return c - (a*x+b)**-alpha
[ "def", "pow4", "(", "x", ",", "alpha", ",", "a", ",", "b", ",", "c", ")", ":", "return", "c", "-", "(", "a", "*", "x", "+", "b", ")", "**", "-", "alpha" ]
pow4 Parameters ---------- x: int alpha: float a: float b: float c: float Returns ------- float c - (a*x+b)**-alpha
[ "pow4" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L152-L168
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
mmf
def mmf(x, alpha, beta, kappa, delta): """Morgan-Mercer-Flodin http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha ...
python
def mmf(x, alpha, beta, kappa, delta): """Morgan-Mercer-Flodin http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha ...
[ "def", "mmf", "(", "x", ",", "alpha", ",", "beta", ",", "kappa", ",", "delta", ")", ":", "return", "alpha", "-", "(", "alpha", "-", "beta", ")", "/", "(", "1.", "+", "(", "kappa", "*", "x", ")", "**", "delta", ")" ]
Morgan-Mercer-Flodin http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha - beta) / (1. + (kappa * x)**delta)
[ "Morgan", "-", "Mercer", "-", "Flodin", "http", ":", "//", "www", ".", "pisces", "-", "conservation", ".", "com", "/", "growthhelp", "/", "index", ".", "html?morgan_mercer_floden", ".", "htm" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L174-L191
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
exp4
def exp4(x, c, a, b, alpha): """exp4 Parameters ---------- x: int c: float a: float b: float alpha: float Returns ------- float c - np.exp(-a*(x**alpha)+b) """ return c - np.exp(-a*(x**alpha)+b)
python
def exp4(x, c, a, b, alpha): """exp4 Parameters ---------- x: int c: float a: float b: float alpha: float Returns ------- float c - np.exp(-a*(x**alpha)+b) """ return c - np.exp(-a*(x**alpha)+b)
[ "def", "exp4", "(", "x", ",", "c", ",", "a", ",", "b", ",", "alpha", ")", ":", "return", "c", "-", "np", ".", "exp", "(", "-", "a", "*", "(", "x", "**", "alpha", ")", "+", "b", ")" ]
exp4 Parameters ---------- x: int c: float a: float b: float alpha: float Returns ------- float c - np.exp(-a*(x**alpha)+b)
[ "exp4" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L197-L213
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
weibull
def weibull(x, alpha, beta, kappa, delta): """Weibull model http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha - b...
python
def weibull(x, alpha, beta, kappa, delta): """Weibull model http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha - b...
[ "def", "weibull", "(", "x", ",", "alpha", ",", "beta", ",", "kappa", ",", "delta", ")", ":", "return", "alpha", "-", "(", "alpha", "-", "beta", ")", "*", "np", ".", "exp", "(", "-", "(", "kappa", "*", "x", ")", "**", "delta", ")" ]
Weibull model http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha - beta) * np.exp(-(kappa * x)**delta)
[ "Weibull", "model", "http", ":", "//", "www", ".", "pisces", "-", "conservation", ".", "com", "/", "growthhelp", "/", "index", ".", "html?morgan_mercer_floden", ".", "htm" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L239-L256
train
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
janoschek
def janoschek(x, a, beta, k, delta): """http://www.pisces-conservation.com/growthhelp/janoschek.htm Parameters ---------- x: int a: float beta: float k: float delta: float Returns ------- float a - (a - beta) * np.exp(-k*x**delta) """ return a - (a - bet...
python
def janoschek(x, a, beta, k, delta): """http://www.pisces-conservation.com/growthhelp/janoschek.htm Parameters ---------- x: int a: float beta: float k: float delta: float Returns ------- float a - (a - beta) * np.exp(-k*x**delta) """ return a - (a - bet...
[ "def", "janoschek", "(", "x", ",", "a", ",", "beta", ",", "k", ",", "delta", ")", ":", "return", "a", "-", "(", "a", "-", "beta", ")", "*", "np", ".", "exp", "(", "-", "k", "*", "x", "**", "delta", ")" ]
http://www.pisces-conservation.com/growthhelp/janoschek.htm Parameters ---------- x: int a: float beta: float k: float delta: float Returns ------- float a - (a - beta) * np.exp(-k*x**delta)
[ "http", ":", "//", "www", ".", "pisces", "-", "conservation", ".", "com", "/", "growthhelp", "/", "janoschek", ".", "htm", "Parameters", "----------", "x", ":", "int", "a", ":", "float", "beta", ":", "float", "k", ":", "float", "delta", ":", "float" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L262-L278
train
Microsoft/nni
tools/nni_cmd/nnictl.py
parse_args
def parse_args(): '''Definite the arguments users need to follow and input''' parser = argparse.ArgumentParser(prog='nnictl', description='use nnictl command to control nni experiments') parser.add_argument('--version', '-v', action='store_true') parser.set_defaults(func=nni_info) # create subparse...
python
def parse_args(): '''Definite the arguments users need to follow and input''' parser = argparse.ArgumentParser(prog='nnictl', description='use nnictl command to control nni experiments') parser.add_argument('--version', '-v', action='store_true') parser.set_defaults(func=nni_info) # create subparse...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'nnictl'", ",", "description", "=", "'use nnictl command to control nni experiments'", ")", "parser", ".", "add_argument", "(", "'--version'", ",", "'-v'", ","...
Definite the arguments users need to follow and input
[ "Definite", "the", "arguments", "users", "need", "to", "follow", "and", "input" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/nnictl.py#L46-L198
train
Microsoft/nni
tools/nni_cmd/launcher.py
get_log_path
def get_log_path(config_file_name): '''generate stdout and stderr log path''' stdout_full_path = os.path.join(NNICTL_HOME_DIR, config_file_name, 'stdout') stderr_full_path = os.path.join(NNICTL_HOME_DIR, config_file_name, 'stderr') return stdout_full_path, stderr_full_path
python
def get_log_path(config_file_name): '''generate stdout and stderr log path''' stdout_full_path = os.path.join(NNICTL_HOME_DIR, config_file_name, 'stdout') stderr_full_path = os.path.join(NNICTL_HOME_DIR, config_file_name, 'stderr') return stdout_full_path, stderr_full_path
[ "def", "get_log_path", "(", "config_file_name", ")", ":", "stdout_full_path", "=", "os", ".", "path", ".", "join", "(", "NNICTL_HOME_DIR", ",", "config_file_name", ",", "'stdout'", ")", "stderr_full_path", "=", "os", ".", "path", ".", "join", "(", "NNICTL_HOME...
generate stdout and stderr log path
[ "generate", "stdout", "and", "stderr", "log", "path" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L43-L47
train
Microsoft/nni
tools/nni_cmd/launcher.py
print_log_content
def print_log_content(config_file_name): '''print log information''' stdout_full_path, stderr_full_path = get_log_path(config_file_name) print_normal(' Stdout:') print(check_output_command(stdout_full_path)) print('\n\n') print_normal(' Stderr:') print(check_output_command(stderr_full_path))
python
def print_log_content(config_file_name): '''print log information''' stdout_full_path, stderr_full_path = get_log_path(config_file_name) print_normal(' Stdout:') print(check_output_command(stdout_full_path)) print('\n\n') print_normal(' Stderr:') print(check_output_command(stderr_full_path))
[ "def", "print_log_content", "(", "config_file_name", ")", ":", "stdout_full_path", ",", "stderr_full_path", "=", "get_log_path", "(", "config_file_name", ")", "print_normal", "(", "' Stdout:'", ")", "print", "(", "check_output_command", "(", "stdout_full_path", ")", "...
print log information
[ "print", "log", "information" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L49-L56
train
Microsoft/nni
tools/nni_cmd/launcher.py
get_nni_installation_path
def get_nni_installation_path(): ''' Find nni lib from the following locations in order Return nni root directory if it exists ''' def try_installation_path_sequentially(*sitepackages): '''Try different installation path sequentially util nni is found. Return None if nothing is found ...
python
def get_nni_installation_path(): ''' Find nni lib from the following locations in order Return nni root directory if it exists ''' def try_installation_path_sequentially(*sitepackages): '''Try different installation path sequentially util nni is found. Return None if nothing is found ...
[ "def", "get_nni_installation_path", "(", ")", ":", "def", "try_installation_path_sequentially", "(", "*", "sitepackages", ")", ":", "'''Try different installation path sequentially util nni is found.\n Return None if nothing is found\n '''", "def", "_generate_installation_p...
Find nni lib from the following locations in order Return nni root directory if it exists
[ "Find", "nni", "lib", "from", "the", "following", "locations", "in", "order", "Return", "nni", "root", "directory", "if", "it", "exists" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L58-L96
train
Microsoft/nni
tools/nni_cmd/launcher.py
start_rest_server
def start_rest_server(port, platform, mode, config_file_name, experiment_id=None, log_dir=None, log_level=None): '''Run nni manager process''' nni_config = Config(config_file_name) if detect_port(port): print_error('Port %s is used by another process, please reset the port!\n' \ 'You could u...
python
def start_rest_server(port, platform, mode, config_file_name, experiment_id=None, log_dir=None, log_level=None): '''Run nni manager process''' nni_config = Config(config_file_name) if detect_port(port): print_error('Port %s is used by another process, please reset the port!\n' \ 'You could u...
[ "def", "start_rest_server", "(", "port", ",", "platform", ",", "mode", ",", "config_file_name", ",", "experiment_id", "=", "None", ",", "log_dir", "=", "None", ",", "log_level", "=", "None", ")", ":", "nni_config", "=", "Config", "(", "config_file_name", ")"...
Run nni manager process
[ "Run", "nni", "manager", "process" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L98-L140
train
Microsoft/nni
tools/nni_cmd/launcher.py
set_trial_config
def set_trial_config(experiment_config, port, config_file_name): '''set trial configuration''' request_data = dict() request_data['trial_config'] = experiment_config['trial'] response = rest_put(cluster_metadata_url(port), json.dumps(request_data), REST_TIME_OUT) if check_response(response): ...
python
def set_trial_config(experiment_config, port, config_file_name): '''set trial configuration''' request_data = dict() request_data['trial_config'] = experiment_config['trial'] response = rest_put(cluster_metadata_url(port), json.dumps(request_data), REST_TIME_OUT) if check_response(response): ...
[ "def", "set_trial_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "request_data", "=", "dict", "(", ")", "request_data", "[", "'trial_config'", "]", "=", "experiment_config", "[", "'trial'", "]", "response", "=", "rest_put", "(...
set trial configuration
[ "set", "trial", "configuration" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L142-L155
train
Microsoft/nni
tools/nni_cmd/launcher.py
set_local_config
def set_local_config(experiment_config, port, config_file_name): '''set local configuration''' #set machine_list request_data = dict() if experiment_config.get('localConfig'): request_data['local_config'] = experiment_config['localConfig'] if request_data['local_config'] and request_data...
python
def set_local_config(experiment_config, port, config_file_name): '''set local configuration''' #set machine_list request_data = dict() if experiment_config.get('localConfig'): request_data['local_config'] = experiment_config['localConfig'] if request_data['local_config'] and request_data...
[ "def", "set_local_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "#set machine_list", "request_data", "=", "dict", "(", ")", "if", "experiment_config", ".", "get", "(", "'localConfig'", ")", ":", "request_data", "[", "'local_con...
set local configuration
[ "set", "local", "configuration" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L157-L176
train
Microsoft/nni
tools/nni_cmd/launcher.py
set_remote_config
def set_remote_config(experiment_config, port, config_file_name): '''Call setClusterMetadata to pass trial''' #set machine_list request_data = dict() request_data['machine_list'] = experiment_config['machineList'] if request_data['machine_list']: for i in range(len(request_data['machine_list...
python
def set_remote_config(experiment_config, port, config_file_name): '''Call setClusterMetadata to pass trial''' #set machine_list request_data = dict() request_data['machine_list'] = experiment_config['machineList'] if request_data['machine_list']: for i in range(len(request_data['machine_list...
[ "def", "set_remote_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "#set machine_list", "request_data", "=", "dict", "(", ")", "request_data", "[", "'machine_list'", "]", "=", "experiment_config", "[", "'machineList'", "]", "if", ...
Call setClusterMetadata to pass trial
[ "Call", "setClusterMetadata", "to", "pass", "trial" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L178-L200
train
Microsoft/nni
tools/nni_cmd/launcher.py
setNNIManagerIp
def setNNIManagerIp(experiment_config, port, config_file_name): '''set nniManagerIp''' if experiment_config.get('nniManagerIp') is None: return True, None ip_config_dict = dict() ip_config_dict['nni_manager_ip'] = { 'nniManagerIp' : experiment_config['nniManagerIp'] } response = rest_put(clu...
python
def setNNIManagerIp(experiment_config, port, config_file_name): '''set nniManagerIp''' if experiment_config.get('nniManagerIp') is None: return True, None ip_config_dict = dict() ip_config_dict['nni_manager_ip'] = { 'nniManagerIp' : experiment_config['nniManagerIp'] } response = rest_put(clu...
[ "def", "setNNIManagerIp", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "if", "experiment_config", ".", "get", "(", "'nniManagerIp'", ")", "is", "None", ":", "return", "True", ",", "None", "ip_config_dict", "=", "dict", "(", ")", ...
set nniManagerIp
[ "set", "nniManagerIp" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L202-L217
train
Microsoft/nni
tools/nni_cmd/launcher.py
set_frameworkcontroller_config
def set_frameworkcontroller_config(experiment_config, port, config_file_name): '''set kubeflow configuration''' frameworkcontroller_config_data = dict() frameworkcontroller_config_data['frameworkcontroller_config'] = experiment_config['frameworkcontrollerConfig'] response = rest_put(cluster_metadata_ur...
python
def set_frameworkcontroller_config(experiment_config, port, config_file_name): '''set kubeflow configuration''' frameworkcontroller_config_data = dict() frameworkcontroller_config_data['frameworkcontroller_config'] = experiment_config['frameworkcontrollerConfig'] response = rest_put(cluster_metadata_ur...
[ "def", "set_frameworkcontroller_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "frameworkcontroller_config_data", "=", "dict", "(", ")", "frameworkcontroller_config_data", "[", "'frameworkcontroller_config'", "]", "=", "experiment_config", ...
set kubeflow configuration
[ "set", "kubeflow", "configuration" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L257-L274
train
Microsoft/nni
tools/nni_cmd/launcher.py
set_experiment
def set_experiment(experiment_config, mode, port, config_file_name): '''Call startExperiment (rest POST /experiment) with yaml file content''' request_data = dict() request_data['authorName'] = experiment_config['authorName'] request_data['experimentName'] = experiment_config['experimentName'] reque...
python
def set_experiment(experiment_config, mode, port, config_file_name): '''Call startExperiment (rest POST /experiment) with yaml file content''' request_data = dict() request_data['authorName'] = experiment_config['authorName'] request_data['experimentName'] = experiment_config['experimentName'] reque...
[ "def", "set_experiment", "(", "experiment_config", ",", "mode", ",", "port", ",", "config_file_name", ")", ":", "request_data", "=", "dict", "(", ")", "request_data", "[", "'authorName'", "]", "=", "experiment_config", "[", "'authorName'", "]", "request_data", "...
Call startExperiment (rest POST /experiment) with yaml file content
[ "Call", "startExperiment", "(", "rest", "POST", "/", "experiment", ")", "with", "yaml", "file", "content" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L276-L341
train
Microsoft/nni
tools/nni_cmd/launcher.py
launch_experiment
def launch_experiment(args, experiment_config, mode, config_file_name, experiment_id=None): '''follow steps to start rest server and start experiment''' nni_config = Config(config_file_name) # check packages for tuner if experiment_config.get('tuner') and experiment_config['tuner'].get('builtinTunerName...
python
def launch_experiment(args, experiment_config, mode, config_file_name, experiment_id=None): '''follow steps to start rest server and start experiment''' nni_config = Config(config_file_name) # check packages for tuner if experiment_config.get('tuner') and experiment_config['tuner'].get('builtinTunerName...
[ "def", "launch_experiment", "(", "args", ",", "experiment_config", ",", "mode", ",", "config_file_name", ",", "experiment_id", "=", "None", ")", ":", "nni_config", "=", "Config", "(", "config_file_name", ")", "# check packages for tuner", "if", "experiment_config", ...
follow steps to start rest server and start experiment
[ "follow", "steps", "to", "start", "rest", "server", "and", "start", "experiment" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L343-L492
train
Microsoft/nni
tools/nni_cmd/launcher.py
resume_experiment
def resume_experiment(args): '''resume an experiment''' experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() experiment_id = None experiment_endTime = None #find the latest stopped experiment if not args.id: print_error('Please set experiment id...
python
def resume_experiment(args): '''resume an experiment''' experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() experiment_id = None experiment_endTime = None #find the latest stopped experiment if not args.id: print_error('Please set experiment id...
[ "def", "resume_experiment", "(", "args", ")", ":", "experiment_config", "=", "Experiments", "(", ")", "experiment_dict", "=", "experiment_config", ".", "get_all_experiments", "(", ")", "experiment_id", "=", "None", "experiment_endTime", "=", "None", "#find the latest ...
resume an experiment
[ "resume", "an", "experiment" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L494-L521
train
Microsoft/nni
tools/nni_cmd/launcher.py
create_experiment
def create_experiment(args): '''start a new experiment''' config_file_name = ''.join(random.sample(string.ascii_letters + string.digits, 8)) nni_config = Config(config_file_name) config_path = os.path.abspath(args.config) if not os.path.exists(config_path): print_error('Please set correct co...
python
def create_experiment(args): '''start a new experiment''' config_file_name = ''.join(random.sample(string.ascii_letters + string.digits, 8)) nni_config = Config(config_file_name) config_path = os.path.abspath(args.config) if not os.path.exists(config_path): print_error('Please set correct co...
[ "def", "create_experiment", "(", "args", ")", ":", "config_file_name", "=", "''", ".", "join", "(", "random", ".", "sample", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", ",", "8", ")", ")", "nni_config", "=", "Config", "(", "config_...
start a new experiment
[ "start", "a", "new", "experiment" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher.py#L523-L536
train