Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

classificationLayer

Create a classification output layer

Syntax

coutputlayer = classificationLayer()
coutputlayer = classificationLayer('Name',Name)

Description

coutputlayer = classificationLayer() returns a classification output layer for a neural network. The classification output layer holds the name of the loss function that the software uses for training the network for multi-class classification, the size of the output, and the class labels.

example

coutputlayer = classificationLayer('Name',Name) returns a classification layer with name specified by name.

Examples

collapse all

Create a classification output layer with the name 'coutput'.

coutputlayer = classificationLayer('Name','coutput')
coutputlayer = 

  ClassificationOutputLayer with properties:

            Name: 'coutput'
      ClassNames: {1×0 cell}
      OutputSize: 'auto'

   Hyperparameters
    LossFunction: 'crossentropyex'

The default loss function for classification is cross entropy for $k$ mutually exclusive classes.

Input Arguments

collapse all

Name for the layer, specified as the comma-separated pair consisting of Name and a character vector.

Example: 'Name','coutput'

Data Types: char

Output Arguments

collapse all

Classification output layer, returned as a ClassificationOutputLayer object.

For information on concatenating layers to construct convolutional neural network architecture, see Layer.

More About

collapse all

Cross Entropy Function for k Mutually Exclusive Classes

For multi-class classification problems the software assigns each input to one of the k mutually exclusive classes. The loss (error) function for this case is the cross entropy function for a 1-of-k coding scheme [1]:

E(θ)=i=1nj=1ktijlnyj(xi,θ),

where θ is the parameter vector, tij is the indicator that the ith sample belongs to the jth class, and yj(xi,θ) is the output for sample i. The output yj(xi,θ) can be interpreted as the probability that the network associates ith input with class j, i.e., P(tj=1|xi).

The output unit activation function is the softmax function:

yr(x)=exp(ar(x))j=1kexp(aj(x)),

where 0yr1 and j=1kyj=1.

References

[1] Bishop, C. M. Pattern Recognition and Machine Learning. Springer, New York, NY, 2006.

Introduced in R2016a

Was this topic helpful?