本文整理汇总了Java中org.nd4j.linalg.primitives.Triple.getThird方法的典型用法代码示例。如果您正苦于以下问题:Java Triple.getThird方法的具体用法?Java Triple.getThird怎么用?Java Triple.getThird使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nd4j.linalg.primitives.Triple
的用法示例。
在下文中一共展示了Triple.getThird方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBroadcastShapes
import org.nd4j.linalg.primitives.Triple; //导入方法依赖的package包/类
@Test
public void testBroadcastShapes(){
//Test cases: in1Shape, in2Shape, shapeOf(op(in1,in2))
List<Triple<int[],int[], int[]>> testCases = new ArrayList<>();
testCases.add(new Triple<>(new int[]{3,1}, new int[]{1,4}, new int[]{3,4}));
testCases.add(new Triple<>(new int[]{3,1}, new int[]{3,4}, new int[]{3,4}));
testCases.add(new Triple<>(new int[]{3,4}, new int[]{1,4}, new int[]{3,4}));
testCases.add(new Triple<>(new int[]{3,4,1}, new int[]{1,1,5}, new int[]{3,4,5}));
testCases.add(new Triple<>(new int[]{3,4,1}, new int[]{3,1,5}, new int[]{3,4,5}));
testCases.add(new Triple<>(new int[]{3,1,5}, new int[]{1,4,1}, new int[]{3,4,5}));
testCases.add(new Triple<>(new int[]{3,1,5}, new int[]{1,4,5}, new int[]{3,4,5}));
testCases.add(new Triple<>(new int[]{3,1,5}, new int[]{3,4,5}, new int[]{3,4,5}));
testCases.add(new Triple<>(new int[]{3,1,1,1}, new int[]{1,4,5,6}, new int[]{3,4,5,6}));
testCases.add(new Triple<>(new int[]{1,1,1,6}, new int[]{3,4,5,6}, new int[]{3,4,5,6}));
testCases.add(new Triple<>(new int[]{1,4,5,1}, new int[]{3,1,1,6}, new int[]{3,4,5,6}));
testCases.add(new Triple<>(new int[]{1,6}, new int[]{3,4,5,1}, new int[]{3,4,5,6}));
for(Triple<int[], int[], int[]> t : testCases){
int[] x = t.getFirst();
int[] y = t.getSecond();
int[] exp = t.getThird();
int[] act = Shape.broadcastOutputShape(x,y);
assertArrayEquals(exp,act);
}
}
示例2: getGraphInfo
import org.nd4j.linalg.primitives.Triple; //导入方法依赖的package包/类
private TrainModuleUtils.GraphInfo getGraphInfo() {
Triple<MultiLayerConfiguration, ComputationGraphConfiguration, NeuralNetConfiguration> conf = getConfig();
if (conf == null) {
return null;
}
if (conf.getFirst() != null) {
return TrainModuleUtils.buildGraphInfo(conf.getFirst());
} else if (conf.getSecond() != null) {
return TrainModuleUtils.buildGraphInfo(conf.getSecond());
} else if (conf.getThird() != null) {
return TrainModuleUtils.buildGraphInfo(conf.getThird());
} else {
return null;
}
}
示例3: testSliceGradient
import org.nd4j.linalg.primitives.Triple; //导入方法依赖的package包/类
@Test
public void testSliceGradient() {
Nd4j.getRandom().setSeed(12345);
//Order here: original shape, begin, size
List<Triple<int[], int[], int[]>> testCases = new ArrayList<>();
testCases.add(new Triple<>(new int[]{3, 4}, new int[]{0, 0}, new int[]{3, 4}));
testCases.add(new Triple<>(new int[]{3, 4}, new int[]{1, 1}, new int[]{3, 4}));
testCases.add(new Triple<>(new int[]{3, 4}, new int[]{1, 2}, new int[]{2, 3}));
testCases.add(new Triple<>(new int[]{3, 4, 5}, new int[]{0, 0, 0}, new int[]{3, 4, 5}));
testCases.add(new Triple<>(new int[]{3, 4, 5}, new int[]{1, 1, 1}, new int[]{2, 3, 4}));
testCases.add(new Triple<>(new int[]{3, 4, 5}, new int[]{1, 0, 2}, new int[]{3, 3, 4}));
for (int i = 0; i < testCases.size(); i++) {
Triple<int[], int[], int[]> t = testCases.get(i);
int[] os = t.getFirst();
int[] b = t.getSecond();
int[] e = t.getThird();
INDArray arr = Nd4j.rand(os);
SameDiff sd = SameDiff.create();
SDVariable in = sd.var("in", arr);
SDVariable slice = sd.slice(in, b, e);
SDVariable stdev = sd.standardDeviation(slice, true);
String msg = "i=" + i + ": inShape=" + Arrays.toString(os) + ", begin=" + Arrays.toString(b) + ", end=" + Arrays.toString(e);
log.info("Starting test: " + msg);
GradCheckUtil.checkGradients(sd);
}
}
示例4: call
import org.nd4j.linalg.primitives.Triple; //导入方法依赖的package包/类
@Override
public Triple<VocabWord, VocabWord, Double> call(Triple<String, String, Double> v1) throws Exception {
return new Triple<>((VocabWord) vocab.getValue().wordFor(v1.getFirst()),
(VocabWord) vocab.getValue().wordFor(v1.getSecond()), v1.getThird());
}