Dense

neuralpy.layers.linear.Dense(n_nodes, n_inputs=None, bias=True, name=None)
info

Dense Layer is mostly stable and can be used for any project. In the future, any chance of breaking changes is very low.

A Dense layer is a densely connected Neural Network layer. It performs a linear transformation of the input.

To learn more about Dense layers, please check pytorch documentation for it.

Supported Arguments

  • n_nodes: (Integer) Size of the output sample
  • n_inputs=None: (Integer) Size of the input sample, no need for this argument layers except the initial layer
  • bias=True: (Boolean) If true then uses the bias
  • name=None: (String) Name of the layer, if not provided then automatically calculates a unique name for the layer

Example Code

from neuralpy.models import Sequential
from neuralpy.layers.linear import Dense
# Making the model
model = Sequential()
model.add(Dense(n_nodes=256, n_inputs=28, bias=True, name="Input Layer"))
model.add(Dense(n_nodes=512, bias=True, name="Hidden Layer 1"))
model.add(Dense(n_nodes=10, bias=True, name="Output Layer"))