本文整理汇总了Java中org.nd4j.linalg.dataset.api.DataSet.numExamples方法的典型用法代码示例。如果您正苦于以下问题:Java DataSet.numExamples方法的具体用法?Java DataSet.numExamples怎么用?Java DataSet.numExamples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nd4j.linalg.dataset.api.DataSet
的用法示例。
在下文中一共展示了DataSet.numExamples方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRegressionWritableMatrix
import org.nd4j.linalg.dataset.api.DataSet; //导入方法依赖的package包/类
private static List<List<Writable>> getRegressionWritableMatrix(DataSet dataSet) {
List<List<Writable>> writableMatrix = new ArrayList<>();
for (int i = 0; i < dataSet.numExamples(); i++) {
List<Writable> writables = toRecord(dataSet.getFeatures().getRow(i));
INDArray labelRow = dataSet.getLabels().getRow(i);
for (int j = 0; j < labelRow.shape()[1]; j++) {
writables.add(new DoubleWritable(labelRow.getDouble(j)));
}
writableMatrix.add(writables);
}
return writableMatrix;
}
示例2: getClassificationWritableMatrix
import org.nd4j.linalg.dataset.api.DataSet; //导入方法依赖的package包/类
private static List<List<Writable>> getClassificationWritableMatrix(DataSet dataSet) {
List<List<Writable>> writableMatrix = new ArrayList<>();
for (int i = 0; i < dataSet.numExamples(); i++) {
List<Writable> writables = toRecord(dataSet.getFeatures().getRow(i));
writables.add(new IntWritable(Nd4j.argMax(dataSet.getLabels().getRow(i), 1).getInt(0)));
writableMatrix.add(writables);
}
return writableMatrix;
}
示例3: isClassificationDataSet
import org.nd4j.linalg.dataset.api.DataSet; //导入方法依赖的package包/类
private static boolean isClassificationDataSet(DataSet dataSet) {
INDArray labels = dataSet.getLabels();
return labels.sum(0, 1).getInt(0) == dataSet.numExamples() && labels.shape()[1] > 1;
}
示例4: testFilterAndStrip
import org.nd4j.linalg.dataset.api.DataSet; //导入方法依赖的package包/类
@Test
public void testFilterAndStrip() {
INDArray labels = FeatureUtil.toOutcomeMatrix(new int[]{0,1,2,1,2,2,0,1,2,1},3);
DataSet d = new org.nd4j.linalg.dataset.DataSet(Nd4j.ones(10, 2),labels);
//strip the dataset down to just these labels. Rearrange them such that each label is in the specified position.
d.filterAndStrip(new int[]{1,2});
for(int i = 0; i < d.numExamples(); i++) {
int outcome = d.get(i).outcome();
assertTrue(outcome == 0 || outcome == 1);
}
}