当前位置: 首页>>代码示例>>Java>>正文


Java INDArray.columns方法代码示例

本文整理汇总了Java中org.nd4j.linalg.api.ndarray.INDArray.columns方法的典型用法代码示例。如果您正苦于以下问题:Java INDArray.columns方法的具体用法?Java INDArray.columns怎么用?Java INDArray.columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nd4j.linalg.api.ndarray.INDArray的用法示例。


在下文中一共展示了INDArray.columns方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
public Result run(KieMLContainer kc, Model model, Input input) {
	Result prediction = null;
	List<ModelParam> params = model.getParams();
	if(params == null) {
		throw new IllegalArgumentException("Parameters to configure the input parsing are required!!");
	}
	String transformerName = ParamsUtil.getRequiredStringParam(params, "transformerName");
	Transformer transformer = TransformerFactory.get(transformerName);
	INDArray image = transformer.transform(params, input);
	InputStream isModel = kc.getModelBinInputStream(model);
	INDArray output = getOutput(isModel, image);
	prediction = new Result();
	prediction.setText(output.toString());
	prediction.setPredictions(new HashMap<>());
	for (int i = 0; i < output.columns(); i++) {
		if(output.getDouble(i) == 0d) { 
			continue;
		}
		prediction.getPredictions().put(model.getLabels().get(i), output.getDouble(i));
	}
	return prediction;
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:23,代码来源:DL4JKieMLProvider.java

示例2: getDoubles

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
private static double[][] getDoubles(INDArray matrix) {
  double[][] data = new double[matrix.rows()][matrix.columns()];
  for (int i = 0; i < data.length; i++) {
    for (int j = 0; j < data[0].length; j++) {
      data[i][j] = matrix.getDouble(i, j);
    }
  }
  return data;
}
 
开发者ID:tteofili,项目名称:par2hier,代码行数:10,代码来源:Par2HierUtils.java

示例3: toCsv

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
private String toCsv(DataSetIterator it, List<Integer> labels, int[] shape) {
    if (it.numExamples() != labels.size()) {
        throw new IllegalStateException(
                String.format("numExamples == %d != labels.size() == %d",
                        it.numExamples(), labels.size()));
    }

    StringBuffer sb = new StringBuffer();
    int l = 0;

    while (it.hasNext()) {
        INDArray features = it.next(1).getFeatures();

        if (!(Arrays.equals(features.shape(), shape))) {
            throw new IllegalStateException(String.format("wrong shape: got %s, expected",
                    Arrays.toString(features.shape()), Arrays.toString(shape)));
        }

        // Prepend the label
        sb.append(labels.get(l)).append(": ");
        l++;

        for (int i=0; i<features.columns(); i++) {
            sb.append(features.getColumn(i));

            if (i < features.columns()-1) {
                sb.append(", ");
            }
        }

        sb.append("\n");
    }

    return sb.toString();
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:36,代码来源:NormalizeUciData.java

示例4: isTransitive

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
private boolean isTransitive(double[] ilpSolution, int n) {

		double[][] adjacencyMatrix = new double[n][n];
		int k = 0;
		for (int i = 0; i < n; i++) {
			adjacencyMatrix[i][i] = 1;
			for (int j = i + 1; j < n; j++) {
				adjacencyMatrix[i][j] = ilpSolution[k];
				adjacencyMatrix[j][i] = ilpSolution[k];
				k++;
			}
		}

		INDArray m = new NDArray(adjacencyMatrix);
		INDArray m2 = m.mmul(m);

		System.out.println(m);

		for (int i = 0; i < m.rows(); i++) {
			for (int j = 0; j < m.columns(); j++) {
				if (m2.getDouble(i, j) > 0 && m.getDouble(i, j) == 0) {
					System.out.println(i + " " + j + " " + m2.getDouble(i, j) + " " + m.getDouble(i, j));
					return false;
				}
			}
		}

		return true;
	}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:30,代码来源:ILPClusterer_Cplex.java

示例5: getMaxValueIndex

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
private static int getMaxValueIndex(INDArray indArray) {
    int maxIndex = 0;
    float maxValue = Float.MIN_VALUE;
    for (int i = 0; i < indArray.columns(); i++) {
        float value = indArray.getFloat(i);
        if (maxValue <= value) {
            maxValue = value;
            maxIndex = i;
        }
    }
    return maxIndex;
}
 
开发者ID:scaliby,项目名称:ceidg-captcha,代码行数:13,代码来源:OutputLabelerImpl.java

示例6: Evaluation

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
public Evaluation (INDArray logits, INDArray labels) {
    this.logits = logits;
    this.labels = labels;
    this.examples = labels.rows();
    this.patterns = labels.columns();
    this.confusionMatrix = new int[patterns][patterns];
    this.precision = new double[patterns];
    this.recall = new double[patterns];
    this.accuracy = 0.0;
}
 
开发者ID:IsaacChanghau,项目名称:NeuralNetworksLite,代码行数:11,代码来源:Evaluation.java

示例7: binomial

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
private INDArray binomial(INDArray x, Random rng) {
    INDArray y = Nd4j.create(new double[x.rows() * x.columns()], new int[] { x.rows(), x.columns() });
    for (int i = 0; i < x.rows(); i++) {
        for (int j = 0; j < x.columns(); j++) { y.put(i, j, RandomGenerator.binomial(1, x.getDouble(i, j), rng)); }
    }
    return y;
}
 
开发者ID:IsaacChanghau,项目名称:NeuralNetworksLite,代码行数:8,代码来源:RestrictedBoltzmannMachine.java

示例8: getCorruptedInput

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
private INDArray getCorruptedInput(INDArray x, double corruptionLevel) {
    INDArray corruptedInput = Nd4j.create(new double[x.rows() * x.columns()], new int[] { x.rows(), x.columns() });
    // add masking noise
    for (int i = 0; i < x.rows(); i++) {
        for (int j = 0; j < x.columns(); j++) {
            double rand_ = rng.nextDouble();
            if (rand_ < corruptionLevel) { corruptedInput.put(i, j, Nd4j.scalar(0.0)); }
            else { corruptedInput.put(i, j, x.getDouble(i, j)); }
        }
    }
    return corruptedInput;
}
 
开发者ID:IsaacChanghau,项目名称:NeuralNetworksLite,代码行数:13,代码来源:DenoisingAutoencoder.java

示例9: outputBinomial

import org.nd4j.linalg.api.ndarray.INDArray; //导入方法依赖的package包/类
public INDArray outputBinomial (INDArray X) {
    INDArray out = output(X);
    INDArray y = Nd4j.create(new double[out.rows() * out.columns()], new int[] { out.rows(), out.columns() });
    for (int i = 0; i < out.rows(); i++) {
        for (int j = 0; j < out.columns(); j++) {
            double value = RandomGenerator.binomial(1, out.getDouble(i, j), rng);
            y.put(i, j, Nd4j.scalar(value));
        }
    }
    return y;
}
 
开发者ID:IsaacChanghau,项目名称:NeuralNetworksLite,代码行数:12,代码来源:DenseLayer.java


注:本文中的org.nd4j.linalg.api.ndarray.INDArray.columns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。