nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/DataSet.java
@Override
    public DataSet get(int i) {
        if (i > numExamples() || i < 0)
            throw new IllegalArgumentException("invalid example number");
        if (i == 0 && numExamples() == 1)
            return this;
        if (getFeatureMatrix().rank() == 4) {
            //ensure rank is preserved
            INDArray slice = getFeatureMatrix().slice(i);
            return new DataSet(slice.reshape(ArrayUtil.combine(new long[] {1}, slice.shape())), getLabels().slice(i));
        }
        return new DataSet(getFeatures().slice(i), getLabels().slice(i));
    }
@Override
    public DataSet get(int i) {
        if (i > numExamples() || i < 0)
            throw new IllegalArgumentException("invalid example number");
        if (i == 0 && numExamples() == 1)
            return this;
        if (getFeatureMatrix().rank() == 4) {
            //ensure rank is preserved
            INDArray slice = getFeatureMatrix().slice(i);
            return new DataSet(slice.reshape(ArrayUtil.combine(new long[] {1}, slice.shape())), getLabels().slice(i));
        }
        return new DataSet(getFeatures().slice(i), getLabels().slice(i));
    }
@ Override public DataSet get ( int i ) { if ( i > numExamples ( ) || i < 0 ) throw new IllegalArgumentException ( "invalid example number" ) ; if ( i == 0 && numExamples ( ) == 1 ) return this ; if ( getFeatureMatrix ( ) . rank ( ) == 4 ) { //ensure rank is preserved INDArray slice = getFeatureMatrix ( ) . slice ( i ) ; return new DataSet ( slice . reshape ( ArrayUtil . combine ( new long [ ] { 1 } , slice . shape ( ) ) ) , getLabels ( ) . slice ( i ) ) ; } return new DataSet ( getFeatures ( ) . slice ( i ) , getLabels ( ) . slice ( i ) ) ; }
Gets a copy of example i

@param i the example to getFromOrigin
@return the example at i (one example)
Gets a copy of example i