Documentation

FullyConnectedLayer class

Fully connected layer

Description

A fully connected layer class containing input and output size, layer name, and weights and bias data.

Construction

fullconnectlayer= fullyConnectedLayer(outputSize)returns a fully connected layer, in which the software multiplies the input by a matrix and then adds a bias vector.

fullconnectlayer= fullyConnectedLayer(outputSize,Name,Value)returns the fully connected layer, with additional options specified by one or moreName,Valuepair arguments.

For more details on the name-value pair arguments, seefullyConnectedLayer.

Input Arguments

expand all

Size of the output for the fully connected layer, specified as an integer value. For classification problems, if this is the last layer before the softmax layer, then the output size must be equal to the number of classes in the data. For regression problems, if this is the last layer before the regression layer, then the output size must be equal to the number of response variables.

Data Types:single|double

Properties

expand all

Input size for the fully connected layer, stored as a positive integer or'auto'. IfInputSizeis'auto', then the software automatically determines the input size during training.

Data Types:double|char

Output size for the fully connected layer, stored as a positive integer.

Data Types:double

Weights for the fully connected layer, stored as anOutputSize-by-InputSizematrix.

Data Types:single

Biases for the fully connected layer, stored as anOutputSize1矩阵.

Data Types:single

Learning rate factor for the weights, stored as a scalar value.

The software multiplies this factor by the global learning rate to determine the learning rate for the weights in this layer. For example, ifWeightLearnRateFactoris 2, then the learning rate for the weights in this layer is twice the current global learning rate. The software determines the global learning rate based on the settings specified using thetrainingOptionsfunction.

Data Types:double

L2 regularization factor for the weights, stored as a scalar value.

The software multiplies this factor with the global L2 regularization factor to determine the learning rate for the weights in this layer. For example, ifWeightL2Factoris 2, then the L2 regularization for the weights in this layer is twice the global L2 regularization factor. You can specify the global L2 regularization factor using thetrainingOptionsfunction.

Data Types:double

Learning rate factor of the biases, stored as a scalar value.

The software multiplies this factor with the global learning rate to determine the learning rate for the biases in this layer. For example, ifBiasLearnRateFactoris 2, then the learning rate for the biases in this layer is twice the current global learning rate. The software determines the global learning rate based on the settings specified using thetrainingOptionsfunction.

Data Types:double

L2 regularization factor for the biases, stored as a scalar value.

The software multiplies this factor with the global L2 regularization factor to determine the learning rate for the biases in this layer. For example, ifBiasL2Factoris 2, then the L2 regularization for the biases in this layer is twice the global L2 regularization factor. You can specify the global L2 regularization factor using thetrainingOptionsfunction.

Data Types:double

Layer name, specified by a character vector. IfNameis set to'', then the software automatically assigns a name at training time.

Data Types:char

Copy Semantics

Value. To learn how value classes affect copy operations, seeCopying Objects(MATLAB) in the MATLAB®documentation.

Examples

expand all

Create a fully connected layer with an output size of 10.

fullclayer = fullyConnectedLayer(10)
fullclayer = FullyConnectedLayer with properties: Weights: [] Bias: [] WeightLearnRateFactor: 1 WeightL2Factor: 1 BiasLearnRateFactor: 1 BiasL2Factor: 0 InputSize: 'auto' OutputSize: 10 Name: ''

The software determines the input size and initializes the weights and bias at training time.

Algorithms

The default for the initial weights is a Gaussian distribution with a mean of 0 and a standard deviation of 0.01. The default for the initial bias is 0. You can manually change the initialization for the weights and bias. SeeSpecify Initial Weight and Biases in Fully Connected Layer.

Introduced in R2016a

Was this topic helpful?