A fully connected convolution layer, also known as an inner product layer.


class MPSCNNFullyConnected : MPSCNNConvolution


A fully connected layer in a Convolutional Neural Network (CNN) is one where every input channel is connected to every output channel. The kernel width is equal to the width of the source image, and the kernel height is equal to the height of the source image. The width and height of the output is 1 x 1.

A fully connected layer takes an MPSImage object with dimensions source.width x source.height x Ni, convolves it with Weights[No][source.width][source.height][Ni], and produces a 1 x 1 x No output.

Thus, the following conditions must be true:

  • kernelWidth == source.width

  • kernelHeight == source.height

  • clipRect.size.width == 1

  • clipRect.size.height == 1

You can think of a fully connected layer as a matrix multiplication where the image is flattened into a vector of length source.width*source.height*Ni, and the weights are arranged in a matrix of dimension No x (source.width*source.height*Ni) to produce an output vector of length No.

The value of the strideInPixelsX, strideInPixelsY, and groups properties must be 1. The offset property is not applicable and it is ignored. Because the clip rectangle is clamped to the destination image bounds, if the destination is 1 x 1, you do not need to set the clipRect property.



init?(coder: NSCoder, device: MTLDevice)

Initializes a fully connected convolution layer.

init(device: MTLDevice, weights: MPSCNNConvolutionDataSource)

Initializes a fully connected convolution layer.

protocol MPSCNNConvolutionDataSource

The protocol that provides convolution filter weights and bias terms.

class MPSCNNConvolutionDescriptor

A description of the attributes of a convolution kernel.

enum MPSCNNConvolutionFlags

Options used to control how kernel weights are stored and used in the CNN kernels


Inherits From

Conforms To

See Also

Fully Connected Layers

class MPSCNNBinaryFullyConnected

A fully connected convolution layer with binary weights and optionally binarized input image.

class MPSCNNFullyConnectedGradient

A gradient fully connected convolution layer.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software