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

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

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

Nd4j.scalar介绍

[英]Create a scalar nd array with the specified value and offset
[中]使用指定的值和偏移量创建标量nd数组

代码示例

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

  1. @Override
  2. public INDArray putWhere(Number comp, Number put, Condition condition) {
  3. return putWhere(Nd4j.scalar(comp),Nd4j.scalar(put),condition);
  4. }

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

  1. /**
  2. * Inserts the element at the specified index
  3. *
  4. * @param i the row insert into
  5. * @param j the column to insert into
  6. * @param element a scalar ndarray
  7. * @return a scalar ndarray of the element at this index
  8. */
  9. @Override
  10. public IComplexNDArray put(int i, int j, Number element) {
  11. return (IComplexNDArray) super.put(i, j, Nd4j.scalar(element));
  12. }

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

  1. /**
  2. * Fetch a particular number on a multi dimensional scale.
  3. *
  4. * @param indexes the indexes to get a number from
  5. * @return the number at the specified indices
  6. */
  7. @Override
  8. public INDArray getScalar(int... indexes) {
  9. return Nd4j.scalar(getDouble(indexes));
  10. }

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

  1. /**
  2. * @param name
  3. * @param value
  4. * @return
  5. */
  6. public SDVariable scalar(String name, double value) {
  7. return var(name, Nd4j.scalar(value));
  8. }

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

  1. /**
  2. * Returns the element at the specified index
  3. *
  4. * @param i the index of the element to return
  5. * @return a scalar ndarray of the element at this index
  6. */
  7. @Override
  8. public IComplexNDArray getScalar(long i) {
  9. return Nd4j.scalar(getComplex(i));
  10. }

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

  1. @Override
  2. public IComplexNDArray put(INDArrayIndex[] indices, Number element) {
  3. return put(indices, Nd4j.scalar(element));
  4. }

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

  1. @Override
  2. public INDArray putWhere(Number comp, INDArray put, Condition condition) {
  3. return putWhere(Nd4j.scalar(comp),put,condition);
  4. }

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

  1. @Override
  2. public IComplexNDArray put(INDArrayIndex[] indices, IComplexNumber element) {
  3. return put(indices, Nd4j.scalar(element));
  4. }

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

  1. @Override
  2. public IComplexNDArray putScalar(int i, double value) {
  3. return put(i, Nd4j.scalar(value));
  4. }

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

  1. @Override
  2. public INDArray getScalar(long i) {
  3. return Nd4j.scalar(getDouble(i));
  4. }

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

  1. /**
  2. * @param mean row vector of means
  3. * @param std row vector of standard deviations
  4. */
  5. public DistributionStats(@NonNull INDArray mean, @NonNull INDArray std) {
  6. Transforms.max(std, Nd4j.EPS_THRESHOLD, false);
  7. if (std.min(1) == Nd4j.scalar(Nd4j.EPS_THRESHOLD)) {
  8. logger.info("API_INFO: Std deviation found to be zero. Transform will round up to epsilon to avoid nans.");
  9. }
  10. this.mean = mean;
  11. this.std = std;
  12. }

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

  1. /**
  2. *
  3. * @param x
  4. * @return
  5. */
  6. public static INDArray computeAbsoluteStep(INDArray x) {
  7. INDArray relStep = pow(Nd4j.scalar(Nd4j.EPS_THRESHOLD),0.5);
  8. return computeAbsoluteStep(relStep,x);
  9. }

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

  1. @Override
  2. public void multiplyBy(double num) {
  3. getFeatures().muli(Nd4j.scalar(num));
  4. }

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

  1. public void fit(DataSet dataSet) {
  2. mean = dataSet.getFeatureMatrix().mean(0);
  3. std = dataSet.getFeatureMatrix().std(0);
  4. std.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD));
  5. if (std.min(1) == Nd4j.scalar(Nd4j.EPS_THRESHOLD))
  6. logger.info("API_INFO: Std deviation found to be zero. Transform will round upto epsilon to avoid nans.");
  7. }

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

  1. public static void normalizeMatrix(INDArray toNormalize) {
  2. INDArray columnMeans = toNormalize.mean(0);
  3. toNormalize.subiRowVector(columnMeans);
  4. INDArray std = toNormalize.std(0);
  5. std.addi(Nd4j.scalar(1e-12));
  6. toNormalize.diviRowVector(std);
  7. }

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

  1. public Choose(String opName, INDArray[] inputs, Condition condition) {
  2. super(opName, inputs, null);
  3. if(condition == null) {
  4. throw new ND4JIllegalArgumentException("Must specify a condition.");
  5. }
  6. addInputArgument(inputs);
  7. addIArgument(condition.condtionNum());
  8. addOutputArgument(Nd4j.create(inputs[0].length()),Nd4j.scalar(1.0));
  9. }

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

  1. @Override
  2. public INDArray mmul(INDArray other) {
  3. long[] shape = {rows(), other.columns()};
  4. INDArray result = createUninitialized(shape, 'f');
  5. if (result.isScalar())
  6. return Nd4j.scalar(Nd4j.getBlasWrapper().dot(this, other));
  7. return mmuli(other, result);
  8. }

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

  1. /**
  2. * @Deprecated
  3. * Subtract by the column means and divide by the standard deviation
  4. */
  5. @Deprecated
  6. @Override
  7. public void normalizeZeroMeanZeroUnitVariance() {
  8. INDArray columnMeans = getFeatures().mean(0);
  9. INDArray columnStds = getFeatureMatrix().std(0);
  10. setFeatures(getFeatures().subiRowVector(columnMeans));
  11. columnStds.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD));
  12. setFeatures(getFeatures().diviRowVector(columnStds));
  13. }

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

  1. @Override
  2. public void roundToTheNearest(int roundTo) {
  3. for (int i = 0; i < getFeatures().length(); i++) {
  4. double curr = (double) getFeatures().getScalar(i).element();
  5. getFeatures().put(i, Nd4j.scalar(MathUtils.roundDouble(curr, roundTo)));
  6. }
  7. }

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

  1. /**
  2. *
  3. * @param relStep
  4. * @param x
  5. * @return
  6. */
  7. public static INDArray computeAbsoluteStep(INDArray relStep,INDArray x) {
  8. if(relStep == null) {
  9. relStep = pow(Nd4j.scalar(getEpsRelativeTo(x)),0.5);
  10. }
  11. INDArray signX0 = x.gte(0).muli(2).subi(1);
  12. return signX0.mul(relStep).muli(max(abs(x),1.0));
  13. }

相关文章