Java Code Examples for org.nd4j.linalg.util.ArrayUtil#range()

The following examples show how to use org.nd4j.linalg.util.ArrayUtil#range() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseConvolution.java    From nd4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray conv2d(IComplexNDArray input, IComplexNDArray kernel, Convolution.Type type) {
    int[] axes = input.shape().length < 2 ? ArrayUtil.range(0, 1)
                    : ArrayUtil.range(input.shape().length - 2, input.shape().length);
    return convn(input, kernel, type, axes);
}
 
Example 2
Source File: BaseNDArray.java    From nd4j with Apache License 2.0 3 votes vote down vote up
/**
 * Mainly here for people coming from numpy.
 * This is equivalent to a call to permute
 *
 * @param dimension the dimension to swap
 * @param with      the one to swap it with
 * @return the swapped axes view
 */
@Override
public INDArray swapAxes(int dimension, int with) {
    int[] shape = ArrayUtil.range(0, shape().length);
    shape[dimension] = with;
    shape[with] = dimension;
    return permute(shape);
}
 
Example 3
Source File: BaseConvolution.java    From nd4j with Apache License 2.0 3 votes vote down vote up
/**
 * 2d convolution (aka the last 2 dimensions
 *
 * @param input  the input to op
 * @param kernel the kernel to convolve with
 * @param type
 * @return
 */
@Override
public INDArray conv2d(INDArray input, INDArray kernel, Convolution.Type type) {
    int[] axes = input.shape().length < 2 ? ArrayUtil.range(0, 1)
                    : ArrayUtil.range(input.shape().length - 2, input.shape().length);
    return convn(input, kernel, type, axes);
}