Layers

Structs and types

NNJulia.Layers.DenseType
Dense(w::Tensor, b::Tensor, f::Function=identity)
Dense(in::Int64, out::Int64, activ::Function=identity)

This struct represents a Dense layer (fully connected neurons). To initialise a Dense layer, the simplest way is to use the second constructor by giving the input and output size of the layer.

Fields

  • weight: A tensor that contains the weight of the neurones of the layer
  • bias: A tensor that contains the biases of the neurons of the layer
  • activation: The activation function of the layer
source
NNJulia.Layers.SequentialType
Sequential(layers::Vector{T}) where {T<:AbstractLayer}
Sequential(layers::Vararg{T}) where {T<:AbstractLayer}
Sequential()

This struct represents a Sequential, a list of sequential layers.

Field

  • layers: A list of layers
source
NNJulia.Layers.FlattenType
Flatten()

This struct represents a Flatten layer It flatten the input data into a 2 dimentional tensor of shape (n,batchSize) with n = the multiplication of every other dimension's size (except the batchsize) of the original tensor This operation preserve the size of the last dimension.

source

Methods for layers

NNJulia.Layers.parametersFunction
parameters(d::Dense)

Return every trainable tensors of a dense layer (weight and biases)

source
parameters(s::Sequential)

Return an array that contains a reference to every parameters of the layers

source
parameters(d::Flatten)

Does nothing for a flatten layer

source
NNJulia.Layers.add!Function
add!(model::Sequential, layer::AbstractLayer)

Add a layer into the list of layers of the sequential

source