MPSCNNFullyConnected(3) | MetalPerformanceShaders.framework | MPSCNNFullyConnected(3) |
MPSCNNFullyConnected
#import <MPSCNNConvolution.h>
Inherits MPSCNNConvolution.
(nonnull instancetype) - initWithDevice:weights:
(nonnull instancetype) -
initWithDevice:convolutionDescriptor:kernelWeights:biasTerms:flags:
(nullable instancetype) - initWithCoder:device:
(nonnull instancetype) - initWithDevice:
This depends on Metal.framework The MPSCNNFullyConnected specifies a fully connected convolution layer a.k.a. Inner product layer. A fully connected CNN layer is one where every input channel is connected to every output channel. The kernel width is equal to width of source image and the kernel height is equal to the height of source image. Width and height of the output is 1x1. Thus, it takes a srcW x srcH x Ni MPSCNNImage, convolves it with Weights[No][SrcW][srcH][Ni] and produces a 1 x 1 x No output. The following must be true:
kernelWidth == source.width kernelHeight == source.height clipRect.size.width == 1 clipRect.size.height == 1
One can think of a fully connected layer as a matrix multiplication that
flattens an image into a vector of length srcW*srcH*Ni. The weights are
arragned in a matrix of dimension No x (srcW*srcH*Ni) for product output
vectors of length No. The strideInPixelsX, strideInPixelsY, and group must
be 1. Offset is not applicable and is ignored. Since clipRect is clamped to
the destination image bounds, if the destination is 1x1, one doesn't need to
set the clipRect.
Note that one can implement an inner product using MPSCNNConvolution by setting
offset = (kernelWidth/2,kernelHeight/2) clipRect.origin = (ox,oy), clipRect.size = (1,1) strideX = strideY = group = 1
However, using the MPSCNNFullyConnected for this is better for
performance as it lets us choose the most performant method which may not be
possible when using a general convolution. For example, we may internally
use matrix multiplication or special reduction kernels for a specific
platform.
NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead.
Parameters:
Returns:
Reimplemented from MPSCNNConvolution.
Standard init with default properties per filter type
Parameters:
Returns:
Reimplemented from MPSCNNConvolution.
Initializes a convolution kernel WARNING: This API is depreated and will be removed in the future. It cannot be used when training. Also serialization/unserialization wont work for MPSCNNConvolution objects created with this init. Please move onto using initWithDevice:weights:.
Parameters:
Returns:
Reimplemented from MPSCNNConvolution.
Initializes a fully connected kernel
Parameters:
Returns:
Reimplemented from MPSCNNConvolution.
Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.
Mon Jul 9 2018 | Version MetalPerformanceShaders-119.3 |