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

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

本文整理了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

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

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

/**
 * Inserts the element at the specified index
 *
 * @param i       the row insert into
 * @param j       the column to insert into
 * @param element a scalar ndarray
 * @return a scalar ndarray of the element at this index
 */
@Override
public IComplexNDArray put(int i, int j, Number element) {
  return (IComplexNDArray) super.put(i, j, Nd4j.scalar(element));
}

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

/**
 * Fetch a particular number on a multi dimensional scale.
 *
 * @param indexes the indexes to get a number from
 * @return the number at the specified indices
 */
@Override
public INDArray getScalar(int... indexes) {
  return Nd4j.scalar(getDouble(indexes));
}

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

/**
 * @param name
 * @param value
 * @return
 */
public SDVariable scalar(String name, double value) {
  return var(name, Nd4j.scalar(value));
}

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

/**
 * Returns the element at the specified index
 *
 * @param i the index of the element to return
 * @return a scalar ndarray of the element at this index
 */
@Override
public IComplexNDArray getScalar(long i) {
  return Nd4j.scalar(getComplex(i));
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 *
 * @param x
 * @return
 */
public static INDArray computeAbsoluteStep(INDArray x) {
  INDArray relStep = pow(Nd4j.scalar(Nd4j.EPS_THRESHOLD),0.5);
  return computeAbsoluteStep(relStep,x);
}

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

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

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

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

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

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

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

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

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

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

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

/**
 * @Deprecated
 * Subtract by the column means and divide by the standard deviation
 */
@Deprecated
@Override
public void normalizeZeroMeanZeroUnitVariance() {
  INDArray columnMeans = getFeatures().mean(0);
  INDArray columnStds = getFeatureMatrix().std(0);
  setFeatures(getFeatures().subiRowVector(columnMeans));
  columnStds.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD));
  setFeatures(getFeatures().diviRowVector(columnStds));
}

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

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

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

/**
 *
 * @param relStep
 * @param x
 * @return
 */
public static INDArray computeAbsoluteStep(INDArray relStep,INDArray x) {
  if(relStep == null) {
    relStep = pow(Nd4j.scalar(getEpsRelativeTo(x)),0.5);
  }
  INDArray signX0 = x.gte(0).muli(2).subi(1);
  return signX0.mul(relStep).muli(max(abs(x),1.0));
}

相关文章