javadoc and remove deprecated methods. (#231)
Signed-off-by: Robert Altena <Rob@Ra-ai.com>
This commit is contained in:
		
							parent
							
								
									dddc8a1143
								
							
						
					
					
						commit
						25b01f7850
					
				| @ -1149,16 +1149,6 @@ public abstract class BaseNDArray implements INDArray, Iterable { | ||||
|         setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape(), stride(), elementWiseStride(), order, this.dataType(), isEmpty())); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setShape(long[] shape) { | ||||
|         setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride(), elementWiseStride(), ordering(), this.dataType(), isEmpty())); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setStride(long[] stride) { | ||||
|         setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape(), stride, elementWiseStride(), ordering(), this.dataType(), isEmpty())); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setShapeAndStride(int[] shape, int[] stride) { | ||||
|         setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(ArrayUtil.toLongArray(shape), ArrayUtil.toLongArray(stride),  0, ordering(), this.dataType(), false)); | ||||
| @ -1283,29 +1273,16 @@ public abstract class BaseNDArray implements INDArray, Iterable { | ||||
|         return scalar.getDouble(0); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy value for this INDArray | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public Number entropyNumber() { | ||||
|         return entropy(Integer.MAX_VALUE).getDouble(0); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns non-normalized Shannon entropy value for this INDArray | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public Number shannonEntropyNumber() { | ||||
|         return shannonEntropy(Integer.MAX_VALUE).getDouble(0); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Returns log entropy value for this INDArray | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public Number logEntropyNumber() { | ||||
|         return logEntropy(Integer.MAX_VALUE).getDouble(0); | ||||
| @ -2297,37 +2274,6 @@ public abstract class BaseNDArray implements INDArray, Iterable { | ||||
|         return size(0); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public INDArray subArray(long[] offsets, int[] shape, int[] stride) { | ||||
|         Nd4j.getCompressor().autoDecompress(this); | ||||
|         int n = shape.length; | ||||
| 
 | ||||
|         // FIXME: shapeInfo should be used here | ||||
|         if (shape.length < 1) | ||||
|             return create(Nd4j.createBufferDetached(shape)); | ||||
|         if (offsets.length != n) | ||||
|             throw new IllegalArgumentException("Invalid offset " + Arrays.toString(offsets)); | ||||
|         if (stride.length != n) | ||||
|             throw new IllegalArgumentException("Invalid stride " + Arrays.toString(stride)); | ||||
| 
 | ||||
|         if (Shape.contentEquals(shape, shapeOf())) { | ||||
|             if (ArrayUtil.isZero(offsets)) { | ||||
|                 return this; | ||||
|             } else { | ||||
|                 throw new IllegalArgumentException("Invalid subArray offsets"); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         long[] dotProductOffsets = offsets; | ||||
|         int[] dotProductStride = stride; | ||||
| 
 | ||||
|         long offset = Shape.offset(jvmShapeInfo.javaShapeInformation) + NDArrayIndex.offset(dotProductStride, dotProductOffsets); | ||||
|         if (offset >= data().length()) | ||||
|             offset = ArrayUtil.sumLong(offsets); | ||||
| 
 | ||||
|         return create(data, Arrays.copyOf(shape, shape.length), stride, offset, ordering()); | ||||
|     } | ||||
| 
 | ||||
|     protected INDArray create(DataBuffer buffer) { | ||||
|         return Nd4j.create(buffer); | ||||
|     } | ||||
| @ -4016,58 +3962,30 @@ public abstract class BaseNDArray implements INDArray, Iterable { | ||||
|         return Nd4j.getExecutioner().exec(new AMin(this, dimension)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the sum along the specified dimension(s) of this ndarray | ||||
|      * | ||||
|      * @param dimension the dimension to getScalar the sum along | ||||
|      * @return the sum along the specified dimension of this ndarray | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray sum(int... dimension) { | ||||
|         validateNumericalArray("sum", true); | ||||
|         return Nd4j.getExecutioner().exec(new Sum(this, dimension)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the sum along the last dimension of this ndarray | ||||
|      * | ||||
|      * @param dimension the dimension to getScalar the sum along | ||||
|      * @return the sum along the specified dimension of this ndarray | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray sum(boolean keepDim, int... dimension) { | ||||
|         validateNumericalArray("sum", true); | ||||
|         return Nd4j.getExecutioner().exec(new Sum(this, null, keepDim, dimension)); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy along dimension | ||||
|      * @param dimension | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray entropy(int... dimension) { | ||||
|         validateNumericalArray("entropy", false); | ||||
|         return Nd4j.getExecutioner().exec(new Entropy(this, dimension)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns non-normalized Shannon entropy along dimension | ||||
|      * @param dimension | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray shannonEntropy(int... dimension) { | ||||
|         validateNumericalArray("shannonEntropy", false); | ||||
|         return Nd4j.getExecutioner().exec(new ShannonEntropy(this, dimension)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns log entropy along dimension | ||||
|      * @param dimension | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray logEntropy(int... dimension) { | ||||
|         validateNumericalArray("logEntropy", false); | ||||
|  | ||||
| @ -468,16 +468,6 @@ public abstract class BaseSparseNDArray implements ISparseNDArray { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setStride(long... stride) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setShape(long... shape) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public INDArray putScalar(long row, long col, double value) { | ||||
|         return null; | ||||
| @ -1284,17 +1274,10 @@ public abstract class BaseSparseNDArray implements ISparseNDArray { | ||||
| 
 | ||||
|     @Override | ||||
|     public void setShapeAndStride(int[] shape, int[] stride) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setOrder(char order) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public INDArray subArray(long[] offsets, int[] shape, int[] stride) { | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @ -1842,49 +1825,26 @@ public abstract class BaseSparseNDArray implements ISparseNDArray { | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy value for this INDArray | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public Number entropyNumber() { | ||||
|         return entropy(Integer.MAX_VALUE).getDouble(0); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns non-normalized Shannon entropy value for this INDArray | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public Number shannonEntropyNumber() { | ||||
|         return shannonEntropy(Integer.MAX_VALUE).getDouble(0); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Returns log entropy value for this INDArray | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public Number logEntropyNumber() { | ||||
|         return logEntropy(Integer.MAX_VALUE).getDouble(0); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy along dimension | ||||
|      * @param dimension | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray entropy(int... dimension) { | ||||
|         return Nd4j.getExecutioner().exec(new Entropy(this, dimension)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns non-normalized Shannon entropy along dimension | ||||
|      * @param dimension | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public INDArray shannonEntropy(int... dimension) { | ||||
|         return Nd4j.getExecutioner().exec(new ShannonEntropy(this, dimension)); | ||||
|  | ||||
| @ -1016,13 +1016,6 @@ public class BaseSparseNDArrayCOO extends BaseSparseNDArray { | ||||
|         return extendedFlags; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public INDArray subArray(long[] offsets, int[] shape, int[] stride) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the underlying indices of the element of the given index | ||||
|      * such as there really are in the original ndarray | ||||
| @ -1138,16 +1131,6 @@ public class BaseSparseNDArrayCOO extends BaseSparseNDArray { | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setStride(long... stride) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void setShape(long... shape) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * This method returns true if this INDArray is special case: no-value INDArray | ||||
|      * | ||||
|  | ||||
| @ -213,11 +213,6 @@ public abstract class BaseSparseNDArrayCSR extends BaseSparseNDArray { | ||||
|         return shapeInformation; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public INDArray subArray(long[] offsets, int[] shape, int[] stride) { | ||||
|         throw new UnsupportedOperationException(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean equals(Object o) { | ||||
|         //TODO use op | ||||
|  | ||||
| @ -1854,63 +1854,47 @@ public interface INDArray extends Serializable, AutoCloseable { | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy value for this INDArray | ||||
|      * @return | ||||
|      * @return entropy value | ||||
|      */ | ||||
|     Number entropyNumber(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns non-normalized Shannon entropy value for this INDArray | ||||
|      * @return | ||||
|      * @return non-normalized Shannon entropy | ||||
|      */ | ||||
|     Number shannonEntropyNumber(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns log entropy value for this INDArray | ||||
|      * @return | ||||
|      * @return log entropy value | ||||
|      */ | ||||
|     Number logEntropyNumber(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy value for this INDArray along specified dimension(s) | ||||
|      * @return | ||||
|      * @param dimension specified dimension(s) | ||||
|      * @return entropy value | ||||
|      */ | ||||
|     INDArray entropy(int... dimension); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy value for this INDArray along specified dimension(s) | ||||
|      * @return | ||||
|      * Returns Shannon entropy value for this INDArray along specified dimension(s) | ||||
|      * @param dimension specified dimension(s) | ||||
|      * @return Shannon entropy | ||||
|      */ | ||||
|     INDArray shannonEntropy(int... dimension); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns entropy value for this INDArray along specified dimension(s) | ||||
|      * @return | ||||
|      * Returns log entropy value for this INDArray along specified dimension(s) | ||||
|      * @param dimension specified dimension(s) | ||||
|      * @return log entropy value | ||||
|      */ | ||||
|     INDArray logEntropy(int... dimension); | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * stride setter | ||||
|      * @param stride | ||||
|      * @deprecated, use {@link #reshape(int...) } | ||||
|      */ | ||||
|     @Deprecated | ||||
|     void setStride(long... stride); | ||||
| 
 | ||||
|     /** | ||||
|      * Shape setter | ||||
|      * @param shape | ||||
|      * @deprecated, use {@link #reshape(int...) } | ||||
|      */ | ||||
| 
 | ||||
| 
 | ||||
|     @Deprecated | ||||
|     void setShape(long... shape); | ||||
| 
 | ||||
|     /** | ||||
|      * Shape and stride setter | ||||
|      * @param shape | ||||
|      * @param stride | ||||
|      * @param shape new value for shape | ||||
|      * @param stride new value for stride | ||||
|      */ | ||||
|     void setShapeAndStride(int[] shape, int[] stride); | ||||
| 
 | ||||
| @ -1919,15 +1903,7 @@ public interface INDArray extends Serializable, AutoCloseable { | ||||
|      * @param order the ordering to set | ||||
|      */ | ||||
|     void setOrder(char order); | ||||
| 
 | ||||
|     /** | ||||
|      * @param offsets | ||||
|      * @param shape | ||||
|      * @param stride | ||||
|      * @return | ||||
|      */ | ||||
|     INDArray subArray(long[] offsets, int[] shape, int[] stride); | ||||
| 
 | ||||
|      | ||||
|     /** | ||||
|      * Returns the elements at the specified indices | ||||
|      * | ||||
|  | ||||
| @ -96,57 +96,6 @@ public abstract class NDArrayIndex implements INDArrayIndex { | ||||
|         return offset(arr.stride(), Indices.offsets(arr.shape(), indices)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Set the shape and stride for | ||||
|      * new axes based dimensions | ||||
|      * @param arr the array to update | ||||
|      *            the shape/strides for | ||||
|      * @param indexes the indexes to update based on | ||||
|      */ | ||||
|     public static void updateForNewAxes(INDArray arr, INDArrayIndex... indexes) { | ||||
|         int numNewAxes = NDArrayIndex.numNewAxis(indexes); | ||||
|         if (numNewAxes >= 1 && (indexes[0].length() > 1 || indexes[0] instanceof NDArrayIndexAll)) { | ||||
|             List<Long> newShape = new ArrayList<>(); | ||||
|             List<Long> newStrides = new ArrayList<>(); | ||||
|             int currDimension = 0; | ||||
|             for (int i = 0; i < indexes.length; i++) { | ||||
|                 if (indexes[i] instanceof NewAxis) { | ||||
|                     newShape.add(1L); | ||||
|                     newStrides.add(0L); | ||||
|                 } else { | ||||
|                     newShape.add(arr.size(currDimension)); | ||||
|                     newStrides.add(arr.size(currDimension)); | ||||
|                     currDimension++; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             while (currDimension < arr.rank()) { | ||||
|                 newShape.add((long) currDimension); | ||||
|                 newStrides.add((long) currDimension); | ||||
|                 currDimension++; | ||||
|             } | ||||
| 
 | ||||
|             long[] newShapeArr = Longs.toArray(newShape); | ||||
|             long[] newStrideArr = Longs.toArray(newStrides); | ||||
| 
 | ||||
|             // FIXME: this is wrong, it breaks shapeInfo immutability | ||||
|             arr.setShape(newShapeArr); | ||||
|             arr.setStride(newStrideArr); | ||||
| 
 | ||||
| 
 | ||||
|         } else { | ||||
|             if (numNewAxes > 0) { | ||||
|                 long[] newShape = Longs.concat(ArrayUtil.toLongArray(ArrayUtil.nTimes(numNewAxes, 1)), arr.shape()); | ||||
|                 long[] newStrides = Longs.concat(new long[numNewAxes], arr.stride()); | ||||
|                 arr.setShape(newShape); | ||||
|                 arr.setStride(newStrides); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Compute the offset given an array of offsets. | ||||
|      * The offset is computed(for both fortran an d c ordering) as: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user