deephyper.nas.spacelib.tabular.feed_forward.FeedForwardSpace#

class deephyper.nas.spacelib.tabular.feed_forward.FeedForwardSpace(input_shape, output_shape, batch_size=None, seed=None, regression=True, num_units=(1, 11), num_layers=10)[source]#

Bases: KSearchSpace

Simple search space for a feed-forward neural network. No skip-connection. Looking over the number of units per layer and the number of layers.

Parameters:
  • input_shape (tuple, optional) – True shape of inputs (no batch size dimension). Defaults to (2,).

  • output_shape (tuple, optional) – True shape of outputs (no batch size dimension).. Defaults to (1,).

  • num_layers (int, optional) – Maximum number of layers to have. Defaults to 10.

  • num_units (tuple, optional) – Range of number of units such as range(start, end, step_size). Defaults to (1, 11).

  • regression (bool, optional) – A boolean defining if the model is a regressor or a classifier. Defaults to True.

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_model

Create the tensors corresponding to the search_space.

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_ops

Set the operations for each node of each cell of the search_space.

set_output_node

Set the output node of the search_space.

Attributes

depth

input

longest_path

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.

output

size

Size of the search space define by the search_space

variable_nodes

Iterator of VariableNodes of the search_space.

add_node(node)#

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.

build()[source]#

Build the current graph search space.

choices()#

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)#

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)#

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

sample(choice=None)#

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))