Skip to content

DnnLayer

DnnLayer

softneuro.core.DnnLayer(*args, **kwargs)

DnnLayer class is the basic element of DnnNet.

This is a private class of softneuro, instance can not be constructed directly,users can get DnnLayer instance using DnnNet.add_layer(), DnnNet.get_input_layer(), DnnNet.get_output_layer(), etc.

Attributes

  • attrs: Attribuites of the layer.
  • child_net: child net.
  • compiled_routine_desc: Routine descriptor of the compiled routine.
  • compiled_routine_params: Parameters of the compiled routine.
  • index: index of the layer in the owner DnnNet.
  • inputs: A series of DnnLayerInput objects of the layer.
  • is_constant: whether the layer is constant or not.
  • is_failed: whether the layer is failed to parse, routinize, precompile or compile.
  • is_immutable: whether the layer is immutable or not.
  • is_mutable: whether the layer is immutable or not.
  • name: Name of the layer.
  • owner: DnnNet that the layer belongs to.
  • params: Parameters of the layer.
  • parsed_params: Parsed parameters of the layer .
  • routine_desc: Routine descriptor of the layer such as cpu/naive, cpu/neon.
  • routine_params: Parameters of the routine.
  • state: State of dnn layer.
  • type: Type of the layer.
  • outputs: A series of DnnLayerOutput objects of the layer.
  • weights: A series of weights in the layer.

connect

DnnLayer.connect(i_output_index, i_next_layer, i_input_index=-1)

Connect an output of the layer to an input of another succeeding layer.

Arguments

  • i_output_index: The index of output to connect.
  • i_next_layer: A succeeding DnnLayer object to be connected.
  • i_input_index: The index of input on the succeeding layer.

disconnect

DnnLayer.disconnect(i_output_index, i_next_layer, i_input_index)

Disconnect an output of the layer from an input of another succeeding layer.

Arguments

  • i_output_index: The index of output to disconnect.
  • i_next_layer: A succeeding DnnLayer object to be disconnected.
  • i_input_index: The index of input on the succeeding layer.

disconnect_all

DnnLayer.disconnect_all()

Disconnects the layer from other layers.


get_input

DnnLayer.get_input(input_index)

Gets input object DnnLayerInput of the layer.

Arguments

  • input_index: The input index of the interest.

Returns

Type : DnnLayerInput,input of the layer.


get_output

DnnLayer.get_output(output_index)

Gets output object DnnLayerOutput of the layer.

Arguments

  • output_index: The input index of the interest.

Returns

Type : DnnLayerOutput,output of the layer.


set_weight

DnnLayer.set_weight(key, val)

Sets weight to the layer.

Arguments

  • key: A string for the name of the weight.
  • val: An object for the weight values, any of the following data types.

Data types for val

  • int
  • float
  • numpy.float
  • numpy.ndarray
  • Tensor