deephyper.nas.NxSearchSpace#

class deephyper.nas.NxSearchSpace(seed=None, **kwargs)[source]#

Bases: abc.ABC

A NxSearchSpace is an search_space based on a networkx graph.

Methods

add_node

Add a new node to the search_space.

build

Build the current graph search space.

choices

Gives the possible choices for each decision variable of the search space.

connect

Create a new connection in the KSearchSpace graph.

create_tensor_aux

Recursive function to create the tensors from the graph.

denormalize

Denormalize a sequence of normalized indexes to get a sequence of absolute indexes.

plot

sample

Sample a tf.keras.Model from the search space.

set_output_node

Set the output node of the search_space.

Attributes

max_num_ops

Returns the maximum number of operations accross all VariableNodes of the struct.

mime_nodes

Iterator of MimeNodes of the search_space.

nodes

Nodes of the current KSearchSpace.

num_nodes

Returns the number of VariableNodes in the current Structure.

size

Size of the search space define by the search_space

variable_nodes

Iterator of VariableNodes of the search_space.

add_node(node)[source]#

Add a new node to the search_space.

Parameters

node (Node) – node to add to the search_space.

Raises
  • TypeError – if ‘node’ is not an instance of Node.

  • NodeAlreadyAdded – if ‘node’ has already been added to the search_space.

abstract build()[source]#

Build the current graph search space.

abstract choices()[source]#

Gives the possible choices for each decision variable of the search space.

Returns

A list of tuple where each element corresponds to a discrete variable represented by (low, high).

Return type

list

connect(node1, node2)[source]#

Create a new connection in the KSearchSpace graph.

The edge created corresponds to : node1 -> node2.

Parameters
Raises

StructureHasACycle – if the new edge is creating a cycle.

denormalize(indexes)[source]#

Denormalize a sequence of normalized indexes to get a sequence of absolute indexes. Useful when you want to compare the number of different search_spaces.

Parameters

indexes (Iterable) – a sequence of normalized indexes.

Returns

A list of absolute indexes corresponding to operations choosen with relative indexes of indexes.

Return type

list

property max_num_ops#

Returns the maximum number of operations accross all VariableNodes of the struct.

Returns

maximum number of Operations for a VariableNode in the current Structure.

Return type

int

property mime_nodes#

Iterator of MimeNodes of the search_space.

Returns

iterator of MimeNodes of the search_space.

Return type

(Iterator(MimeNode))

property nodes#

Nodes of the current KSearchSpace.

Returns

nodes of the current KSearchSpace.

Return type

iterator

property num_nodes#

Returns the number of VariableNodes in the current Structure.

Returns

number of VariableNodes in the current Structure.

Return type

int

abstract sample(choice=None)[source]#

Sample a tf.keras.Model from the search space.

Parameters

choice (list, optional) – A list of decision for the operations of this search space. Defaults to None, will generate a random sample.

Returns

A Tensorflow Keras model.

Return type

tf.keras.Model

property size#

Size of the search space define by the search_space

property variable_nodes#

Iterator of VariableNodes of the search_space.

Returns

generator of VariablesNodes of the search_space.

Return type

(Iterator(VariableNode))