Class Convolution1DLayer

    • Method Detail

      • backpropGradient

        public Pair<Gradient,​INDArray> backpropGradient​(INDArray epsilon,
                                                              LayerWorkspaceMgr workspaceMgr)
        Description copied from interface: Layer
        Calculate the gradient relative to the error in the next layer
        Specified by:
        backpropGradient in interface Layer
        Overrides:
        backpropGradient in class ConvolutionLayer
        Parameters:
        epsilon - w^(L+1)*delta^(L+1). Or, equiv: dC/da, i.e., (dC/dz)*(dz/da) = dC/da, where C is cost function a=sigma(z) is activation.
        workspaceMgr - Workspace manager
        Returns:
        Pair where Gradient is gradient for this layer, INDArray is epsilon (activation gradient) needed by next layer, but before element-wise multiply by sigmaPrime(z). So for standard feed-forward layer, if this layer is L, then return.getSecond() == dL/dIn = (w^(L)*(delta^(L))^T)^T. Note that the returned array should be placed in the ArrayType.ACTIVATION_GRAD workspace via the workspace manager
      • preOutput4d

        protected Pair<INDArray,​INDArray> preOutput4d​(boolean training,
                                                            boolean forBackprop,
                                                            LayerWorkspaceMgr workspaceMgr)
        Description copied from class: ConvolutionLayer
        preOutput4d: Used so that ConvolutionLayer subclasses (such as Convolution1DLayer) can maintain their standard non-4d preOutput method, while overriding this to return 4d activations (for use in backprop) without modifying the public API
        Overrides:
        preOutput4d in class ConvolutionLayer
      • preOutput

        protected Pair<INDArray,​INDArray> preOutput​(boolean training,
                                                          boolean forBackprop,
                                                          LayerWorkspaceMgr workspaceMgr)
        Description copied from class: ConvolutionLayer
        PreOutput method that also returns the im2col2d array (if being called for backprop), as this can be re-used instead of being calculated again.
        Overrides:
        preOutput in class ConvolutionLayer
        Parameters:
        training - Train or test time (impacts dropout)
        forBackprop - If true: return the im2col2d array for re-use during backprop. False: return null for second pair entry. Note that it may still be null in the case of CuDNN and the like.
        Returns:
        Pair of arrays: preOutput (activations) and optionally the im2col2d array
      • activate

        public INDArray activate​(boolean training,
                                 LayerWorkspaceMgr workspaceMgr)
        Description copied from interface: Layer
        Perform forward pass and return the activations array with the last set input
        Specified by:
        activate in interface Layer
        Overrides:
        activate in class ConvolutionLayer
        Parameters:
        training - training or test mode
        workspaceMgr - Workspace manager
        Returns:
        the activation (layer output) of the last specified input. Note that the returned array should be placed in the ArrayType.ACTIVATIONS workspace via the workspace manager
      • feedForwardMaskArray

        public Pair<INDArray,​MaskState> feedForwardMaskArray​(INDArray maskArray,
                                                                   MaskState currentMaskState,
                                                                   int minibatchSize)
        Description copied from interface: Layer
        Feed forward the input mask array, setting in the layer as appropriate. This allows different layers to handle masks differently - for example, bidirectional RNNs and normal RNNs operate differently with masks (the former sets activations to 0 outside of the data present region (and keeps the mask active for future layers like dense layers), whereas normal RNNs don't zero out the activations/errors )instead relying on backpropagated error arrays to handle the variable length case.
        This is also used for example for networks that contain global pooling layers, arbitrary preprocessors, etc.
        Specified by:
        feedForwardMaskArray in interface Layer
        Overrides:
        feedForwardMaskArray in class ConvolutionLayer
        Parameters:
        maskArray - Mask array to set
        currentMaskState - Current state of the mask - see MaskState
        minibatchSize - Current minibatch size. Needs to be known as it cannot always be inferred from the activations array due to reshaping (such as a DenseLayer within a recurrent neural network)
        Returns:
        New mask array after this layer, along with the new mask state.