- All Known Subinterfaces:
ActivationReLU<T>,ActivationSigmoid<T>,ActivationTanH<T>,DFunction<T>,FunctionBatchNorm<T>,FunctionElementWiseMult<T>,FunctionLinear<T>,SpatialAveragePooling<T>,SpatialBatchNorm<T>,SpatialConvolve2D<T>,SpatialMaxPooling<T>,SpatialPooling<T>
- All Known Implementing Classes:
ActivationReLU_F32,ActivationReLU_F64,ActivationSigmoid_F32,ActivationSigmoid_F64,ActivationTanH_F32,ActivationTanH_F64,BaseFunction,BaseSpatialWindow,ElementWiseFunction,FunctionBatchNorm_F32,FunctionBatchNorm_F64,FunctionElementWiseMult_F32,FunctionElementWiseMult_F64,FunctionLinear_F32,FunctionLinear_F64,SpatialAveragePooling_F32,SpatialAveragePooling_F64,SpatialBatchNorm_F32,SpatialBatchNorm_F64,SpatialConvolve2D_F32,SpatialConvolve2D_F64,SpatialMaxPooling_F32,SpatialMaxPooling_F64,SpatialWindowChannel,SpatialWindowImage
public interface Function<T extends Tensor>
High level interface for functions in an Artificial Neural Network. This interface only defines the
the operations in the forwards pass. When learning a network the gradient is typically needed and
those additional operations can be found in DFunction, which extends this interface.
Forwards only implementations potentially have a lower memory foot print, faster specialized implementations, more simplistic implementations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidPerforms forward pass of the function on the provided inputs.int[]Returns the output tensor's shape, without the mini-batch dimension.If the parameters have been set, then this returns the list of parameters.List<int[]>Returns the shape of input tensors, without the mini-batch dimension.Returns the type of tensor it can processvoidinitialize(int... shapeInput) Initializes internal data structures given the shape of the input tensor, minus the stacked input dimension.voidsetParameters(List<T> parameters) Specifies learnable function parameters, e.g.
-
Method Details
-
initialize
void initialize(int... shapeInput) Initializes internal data structures given the shape of the input tensor, minus the stacked input dimension. For example, an input tensor of shape (B,C,D) might be passed into initialize, while the actual input is (N,B,C,D). N is the number of stacked inputs and is allowed to vary after initialization.- Parameters:
shapeInput- Shape of the input tensor- Throws:
IllegalArgumentException- If input tensor shapes are not valid
-
setParameters
Specifies learnable function parameters, e.g. weights for linear functions. This function only needs to be called once each time a parameter has been modified. Must be called before
NOTE: Reference to the parameters may be saved internally and the tensors should not be modified externally.forward(T, T).- Parameters:
parameters- Tensors containing parameters which are optimized. Not modified.
-
getParameters
If the parameters have been set, then this returns the list of parameters. Otherwise null is returned.- Returns:
- List of parameters or null if they have not been set yet
-
forward
Performs forward pass of the function on the provided inputs.Input tensor shape = (N,variable ... ) - N is the mini-batch size - Other dimensions are implementation specific.
- Parameters:
input- Input to the function.output- Output tensor. Modified.
-
getParameterShapes
List<int[]> getParameterShapes()Returns the shape of input tensors, without the mini-batch dimension. Only valid afterinitialize(int...)has been called.- Returns:
- Expected shapes of input tensors. This data structure may be recycled and is modified on the next
call to
initialize(int...).
-
getOutputShape
int[] getOutputShape()Returns the output tensor's shape, without the mini-batch dimension. Only valid afterinitialize(int...)has been called.- Returns:
- Expected shape of output tensor. This data structure may be recycled and is modified on the next
call to
initialize(int...).
-
getTensorType
Returns the type of tensor it can process- Returns:
- Type of tensor
-