brainpy.nn.base.Network#

class brainpy.nn.base.Network(nodes=None, ff_edges=None, fb_edges=None, **kwargs)[source]#

Basic Network class for neural network building in BrainPy.

__init__(nodes=None, ff_edges=None, fb_edges=None, **kwargs)[source]#

Methods

__init__([nodes, ff_edges, fb_edges])

copy([name, shallow])

Returns a copy of the Node.

feedback(ff_output, **shared_kwargs)

The feedback computation function of a node.

forward(ff[, fb, forced_states, ...])

The main computation function of a network.

get_node(name)

init_fb_conn()

Initialize the feedback connections of the network.

init_fb_output([num_batch])

Set the initial node feedback state.

init_ff_conn()

Initialize the feedforward connections of the network.

init_state([num_batch])

Set the initial node state.

initialize([num_batch])

Initialize the whole network.

load_states(filename[, verbose])

Load the model states.

nodes([method, level, include_self])

Collect all children nodes.

offline_fit(targets, ffs[, fbs])

Offline training interface.

online_fit(target, ff[, fb])

Online training fitting interface.

online_init()

Online training initialization interface.

plot_node_graph([fig_size, node_size, ...])

Plot the node graph based on NetworkX package

register_implicit_nodes(nodes)

register_implicit_vars(variables)

replace_graph(nodes, ff_edges[, fb_edges])

rtype

Network

save_states(filename[, variables])

Save the model states.

set_fb_output(state)

Safely set the feedback state of the node.

set_feedback_shapes(fb_shapes)

set_feedforward_shapes(feedforward_shapes)

set_output_shape(shape)

set_state(state)

Safely set the state of the node.

train_vars([method, level, include_self])

The shortcut for retrieving all trainable variables.

unique_name([name, type_])

Get the unique name for this object.

update_graph(new_nodes, new_ff_edges[, ...])

Update current Model's with new nodes and edges, inplace (a copy is not performed).

vars([method, level, include_self])

Collect all variables in this node and the children nodes.

Attributes

data_pass

Offline fitting method.

entry_nodes

First Nodes in the graph held by the Model.

exit_nodes

Last Nodes in the graph held by the Model.

fb_edges

rtype

Sequence[Tuple[Node]]

fb_output

rtype

Optional[TypeVar(Tensor, JaxArray, ndarray)]

fb_receivers

Nodes which receive feedback connections.

fb_senders

Nodes which project feedback connections.

feedback_nodes

Nodes which project feedback connections.

feedback_shapes

Output data size.

feedforward_shapes

Input data size.

ff_edges

rtype

Sequence[Tuple[Node]]

ff_receivers

Nodes which receive feedforward connections.

ff_senders

Nodes which project feedforward connections.

is_feedback_input_supported

is_feedback_supported

is_initialized

rtype

bool

lnodes

rtype

Tuple[Node]

name

nodes_has_feedback

Nodes which receive feedback connections.

output_shape

Output data size.

state

Node current internal state.

trainable

Returns True if at least one Node in the Model is trainable.