private INDArray setIdentityConv(long[] shape, char order, INDArray paramView) {
        final INDArrayIndex[] indArrayIndices = new INDArrayIndex[shape.length];
        for(int i = 2; i < shape.length; i++) {
            if(shape[i] % 2 == 0) {
                throw new IllegalStateException("Cannot use IDENTITY init with parameters of shape "
                        + Arrays.toString(shape) + "! Must have odd sized kernels!");
            }
            indArrayIndices[i] = NDArrayIndex.point(shape[i] / 2);
        }

        paramView.assign(Nd4j.zeros(paramView.shape()));
        final INDArray params =paramView.reshape(order, shape);
        for (int i = 0; i < shape[0]; i++) {
            indArrayIndices[0] = NDArrayIndex.point(i);
            indArrayIndices[1] = NDArrayIndex.point(i);
            params.put(indArrayIndices, Nd4j.ones(1));
        }
        return params;
    }
private INDArray setIdentityConv ( long [ ] shape , char order , INDArray paramView ) { final INDArrayIndex [ ] indArrayIndices = new INDArrayIndex [ shape . length ] ; for ( int i = 2 ; i < shape . length ; i ++ ) { if ( shape [ i ] % 2 == 0 ) { throw new IllegalStateException ( "Cannot use IDENTITY init with parameters of shape " + Arrays . toString ( shape ) + "! Must have odd sized kernels!" ) ; } indArrayIndices [ i ] = NDArrayIndex . point ( shape [ i ] / 2 ) ; } paramView . assign ( Nd4j . zeros ( paramView . shape ( ) ) ) ; final INDArray params = paramView . reshape ( order , shape ) ; for ( int i = 0 ; i < shape [ 0 ] ; i ++ ) { indArrayIndices [ 0 ] = NDArrayIndex . point ( i ) ; indArrayIndices [ 1 ] = NDArrayIndex . point ( i ) ; params . put ( indArrayIndices , Nd4j . ones ( 1 ) ) ; } return params ; }
Set identity mapping for convolution layers. When viewed as an NxM matrix of kernel tensors,
identity mapping is when parameters is a diagonal matrix of identity kernels.
@param shape Shape of parameters
@param order Order of parameters
@param paramView View of parameters
@return A reshaped view of paramView which results in identity mapping when used in convolution layers