org.nd4j.linalg.factory.Nd4j.clearNans()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.nd4j.linalg.factory.Nd4j.clearNans()方法的一些代码示例,展示了Nd4j.clearNans()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.clearNans()方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:clearNans

Nd4j.clearNans介绍

[英]Clear nans from an ndarray
[中]把南斯从黑暗中清除出去

代码示例

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray rsubi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarReverseSubtraction(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray rdivi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarReverseDivision(this, null, result, result.length(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray divi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarDivision(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray muli(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarMultiplication(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray subi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarSubtraction(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * in place subtraction of two matrices
  3. *
  4. * @param other the second ndarray to subtract
  5. * @param result the result ndarray
  6. * @return the result of the subtraction
  7. */
  8. @Override
  9. public INDArray subi(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return subi(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.rsubi(getDouble(0), result);
  15. }
  16. if(!Shape.shapeEquals(this.shape(),other.shape())) {
  17. int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape());
  18. Nd4j.getExecutioner().exec(new BroadcastSubOp(this,other,result,broadcastDimensions),broadcastDimensions);
  19. return result;
  20. }
  21. LinAlgExceptions.assertSameShape(other, result);
  22. Nd4j.getExecutioner().exec(new OldSubOp(this, other,result));
  23. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  24. Nd4j.clearNans(result);
  25. return result;
  26. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * in place (element wise) multiplication of two matrices
  3. *
  4. * @param other the second ndarray to multiply
  5. * @param result the result ndarray
  6. * @return the result of the multiplication
  7. */
  8. @Override
  9. public INDArray muli(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return muli(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.muli(getDouble(0), result);
  15. }
  16. if(!Shape.shapeEquals(this.shape(),other.shape())) {
  17. int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape());
  18. Nd4j.getExecutioner().exec(new BroadcastMulOp(this,other,result,broadcastDimensions),broadcastDimensions);
  19. return result;
  20. }
  21. LinAlgExceptions.assertSameShape(other, result);
  22. Nd4j.getExecutioner().exec(new OldMulOp(this, other, result, length()));
  23. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  24. Nd4j.clearNans(result);
  25. return result;
  26. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * in place (element wise) division of two matrices
  3. *
  4. * @param other the second ndarray to divide
  5. * @param result the result ndarray
  6. * @return the result of the divide
  7. */
  8. @Override
  9. public INDArray divi(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return divi(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.rdivi(getDouble(0), result);
  15. }
  16. if(!Shape.shapeEquals(this.shape(),other.shape())) {
  17. int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape());
  18. Nd4j.getExecutioner().exec(new BroadcastDivOp(this,other,result,broadcastDimensions),broadcastDimensions);
  19. return result;
  20. }
  21. LinAlgExceptions.assertSameShape(other, result);
  22. Nd4j.getExecutioner().exec(new OldDivOp(this, other, result, length()));
  23. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  24. Nd4j.clearNans(result);
  25. return result;
  26. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * in place addition of two matrices
  3. *
  4. * @param other the second ndarray to add
  5. * @param result the result ndarray
  6. * @return the result of the addition
  7. */
  8. @Override
  9. public INDArray addi(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return result.addi(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.addi(getDouble(0), result);
  15. }
  16. if(!Shape.shapeEquals(this.shape(),other.shape())) {
  17. int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape());
  18. result = Nd4j.createUninitialized(Shape.broadcastOutputShape(this.shape(),other.shape()));
  19. Nd4j.getExecutioner().exec(new BroadcastAddOp(this,other,result,broadcastDimensions),broadcastDimensions);
  20. return result;
  21. }
  22. LinAlgExceptions.assertSameShape(other, result);
  23. Nd4j.getExecutioner().exec(new OldAddOp(this, other, result, length()));
  24. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  25. Nd4j.clearNans(result);
  26. return result;
  27. }

代码示例来源:origin: deeplearning4j/nd4j

  1. Nd4j.clearNans(result);

代码示例来源:origin: deeplearning4j/nd4j

  1. Nd4j.clearNans(result);
  2. return result;

代码示例来源:origin: org.nd4j/nd4j-api

  1. @Override
  2. public INDArray rsubi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarReverseSubtraction(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. @Override
  2. public INDArray divi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarDivision(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. @Override
  2. public INDArray subi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarSubtraction(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. @Override
  2. public INDArray rdivi(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarReverseDivision(this, null, result, result.length(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. @Override
  2. public INDArray muli(Number n, INDArray result) {
  3. if (Double.isNaN(n.doubleValue()))
  4. n = Nd4j.EPS_THRESHOLD;
  5. Nd4j.getExecutioner().exec(new ScalarMultiplication(this, null, result, result.lengthLong(), n));
  6. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  7. Nd4j.clearNans(result);
  8. return result;
  9. }

代码示例来源:origin: neo4j-graph-analytics/ml-models

  1. @Override
  2. public INDArray ndOp(INDArray features, INDArray adjacencyMatrix) {
  3. INDArray mean = adjacencyMatrix
  4. .mmul(features)
  5. .diviColumnVector(adjacencyMatrix.sum(1));
  6. // clear NaNs from div by 0 - these entries should have a 0 instead.
  7. Nd4j.clearNans(mean);
  8. return mean;
  9. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. /**
  2. * in place addition of two matrices
  3. *
  4. * @param other the second ndarray to add
  5. * @param result the result ndarray
  6. * @return the result of the addition
  7. */
  8. @Override
  9. public INDArray addi(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return result.addi(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.addi(getDouble(0), result);
  15. }
  16. LinAlgExceptions.assertSameShape(other, result);
  17. Nd4j.getExecutioner().exec(new AddOp(this, other, result));
  18. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  19. Nd4j.clearNans(result);
  20. return result;
  21. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. /**
  2. * in place subtraction of two matrices
  3. *
  4. * @param other the second ndarray to subtract
  5. * @param result the result ndarray
  6. * @return the result of the subtraction
  7. */
  8. @Override
  9. public INDArray subi(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return subi(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.subi(getDouble(0), result);
  15. }
  16. LinAlgExceptions.assertSameShape(other, result);
  17. Nd4j.getExecutioner().exec(new SubOp(this, other, result, length()));
  18. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  19. Nd4j.clearNans(result);
  20. return result;
  21. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. /**
  2. * in place (element wise) division of two matrices
  3. *
  4. * @param other the second ndarray to divide
  5. * @param result the result ndarray
  6. * @return the result of the divide
  7. */
  8. @Override
  9. public INDArray divi(INDArray other, INDArray result) {
  10. if (other.isScalar()) {
  11. return divi(other.getDouble(0), result);
  12. }
  13. if (isScalar()) {
  14. return other.divi(getDouble(0), result);
  15. }
  16. LinAlgExceptions.assertSameShape(other, result);
  17. Nd4j.getExecutioner().exec(new DivOp(this, other, result, length()));
  18. if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
  19. Nd4j.clearNans(result);
  20. return result;
  21. }

相关文章