deephyper.nas.node

deephyper.nas.node

class deephyper.nas.node.ConstantNode(op=None, name='', *args, **kwargs)[source]

Bases: deephyper.nas.node.OperationNode

A ConstantNode represents a node with a fixed operation. It means the agent will not make any new decision for this node. The common use case for this node is to add a tensor in the graph.

>>> import tensorflow as tf
>>> from deephyper.nas.space.node import ConstantNode
>>> from deephyper.nas.space.op.op1d import Dense
>>> cnode = ConstantNode(op=Dense(units=100, activation=tf.nn.relu), name='CNode1')
>>> cnode.op
Dense_100_relu
Parameters
  • op (Operation, optional) – [description]. Defaults to None.

  • name (str, optional) – [description]. Defaults to ‘’.

create_tensor(inputs=None, train=True, seed=None, **kwargs)
property id
num = 0
property op
set_op(op)[source]
static verify_operation(op)
class deephyper.nas.node.MimeNode(node, name='')[source]

Bases: deephyper.nas.node.OperationNode

A MimeNode is a node which reuse an the choice made for an VariableNode, it enable the definition of a Cell based search_space. This node reuse the operation from the mimed VariableNode but only the choice made.

Parameters

node (VariableNode) – the VariableNode to mime.

>>> from deephyper.nas.space.node import VariableNode, MimeNode
>>> from deephyper.nas.space.op.op1d import Dense
>>> vnode = VariableNode()
>>> vnode.add_op(Dense(10))
>>> vnode.add_op(Dense(20))
>>> mnode = MimeNode(vnode)
>>> mnode.add_op(Dense(30))
>>> mnode.add_op(Dense(40))
>>> vnode.set_op(0)
>>> vnode.op
Dense_10
>>> mnode.op
Dense_30
add_op(op)[source]
create_tensor(inputs=None, train=True, seed=None, **kwargs)
property id
num = 0
property num_ops
property op
property ops
set_op()[source]
static verify_operation(op)
class deephyper.nas.node.MirrorNode(node)[source]

Bases: deephyper.nas.node.OperationNode

A MirrorNode is a node which reuse an other, it enable the reuse of tf.keras layers. This node will not add operations to choose.

Parameters

node (Node) – The targeted node to mirror.

>>> from deephyper.nas.space.node import VariableNode, MirrorNode
>>> from deephyper.nas.space.op.op1d import Dense
>>> vnode = VariableNode()
>>> vnode.add_op(Dense(10))
>>> vnode.add_op(Dense(20))
>>> mnode = MirrorNode(vnode)
>>> vnode.set_op(0)
>>> vnode.op
Dense_10
>>> mnode.op
Dense_10
create_tensor(inputs=None, train=True, seed=None, **kwargs)
property id
num = 0
property op
static verify_operation(op)
class deephyper.nas.node.Node(name='', *args, **kwargs)[source]

Bases: object

Represents a node of a graph.

Parameters

name (str) – node name.

create_tensor(*args, **kwargs)[source]
property id
num = 0
property op
static verify_operation(op)[source]
class deephyper.nas.node.OperationNode(name='', *args, **kwargs)[source]

Bases: deephyper.nas.node.Node

create_tensor(inputs=None, train=True, seed=None, **kwargs)[source]
property id
num = 0
property op
static verify_operation(op)
class deephyper.nas.node.VariableNode(name='')[source]

Bases: deephyper.nas.node.OperationNode

This class represents a node of a graph where you have a set of possible operations. It means the agent will have to act to choose one of these operations.

>>> import tensorflow as tf
>>> from deephyper.nas.space.node import VariableNode
>>> vnode = VariableNode("VNode1")
>>> from deephyper.nas.space.op.op1d import Dense
>>> vnode.add_op(Dense(
... units=10,
... activation=tf.nn.relu))
>>> vnode.num_ops
1
>>> vnode.add_op(Dense(
... units=1000,
... activation=tf.nn.tanh))
>>> vnode.num_ops
2
>>> vnode.set_op(0)
>>> vnode.op.units
10
Parameters

name (str) – node name.

add_op(op)[source]
create_tensor(inputs=None, train=True, seed=None, **kwargs)
denormalize(index)[source]

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

Parameters

indexes (float|int) – a normalized index.

Returns

An absolute indexes corresponding to the operation choosen with the relative index of index.

Return type

int

get_op(index)[source]
property id
num = 0
property num_ops
property op
property ops
set_op(index)[source]
static verify_operation(op)