Search in sources :

Example 11 with IndexAccumulation

use of org.nd4j.linalg.api.ops.IndexAccumulation in project nd4j by deeplearning4j.

the class CudaIndexReduceTests method testPinnedIMaxLarge.

@Test
public void testPinnedIMaxLarge() throws Exception {
    // simple way to stop test if we're not on CUDA backend here
    assertEquals("JcublasLevel1", Nd4j.getBlasWrapper().level1().getClass().getSimpleName());
    INDArray array1 = Nd4j.linspace(1, 1024, 1024);
    int idx = ((IndexAccumulation) Nd4j.getExecutioner().exec(new IMax(array1))).getFinalResult();
    System.out.println("Array1: " + array1);
    assertEquals(1023, idx);
}
Also used : INDArray(org.nd4j.linalg.api.ndarray.INDArray) IMax(org.nd4j.linalg.api.ops.impl.indexaccum.IMax) IndexAccumulation(org.nd4j.linalg.api.ops.IndexAccumulation) Test(org.junit.Test)

Example 12 with IndexAccumulation

use of org.nd4j.linalg.api.ops.IndexAccumulation in project nd4j by deeplearning4j.

the class OpExecutionerTests method testIMax.

@Test
public void testIMax() {
    INDArray arr = Nd4j.linspace(1, 10, 10);
    IMax imax = new IMax(arr);
    assertEquals(9, ((IndexAccumulation) Nd4j.getExecutioner().exec(imax)).getFinalResult());
    arr.muli(-1);
    imax = new IMax(arr);
    int maxIdx = ((IndexAccumulation) Nd4j.getExecutioner().exec(imax)).getFinalResult();
    assertEquals(0, maxIdx);
}
Also used : INDArray(org.nd4j.linalg.api.ndarray.INDArray) IMax(org.nd4j.linalg.api.ops.impl.indexaccum.IMax) IndexAccumulation(org.nd4j.linalg.api.ops.IndexAccumulation) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest) Test(org.junit.Test)

Example 13 with IndexAccumulation

use of org.nd4j.linalg.api.ops.IndexAccumulation in project nd4j by deeplearning4j.

the class OpExecutionerTestsC method testIMin.

@Test
public void testIMin() {
    INDArray arr = Nd4j.linspace(1, 10, 10);
    IMin imin = new IMin(arr);
    assertEquals(0, ((IndexAccumulation) Nd4j.getExecutioner().exec(imin)).getFinalResult());
    arr.muli(-1);
    imin = new IMin(arr);
    int minIdx = ((IndexAccumulation) Nd4j.getExecutioner().exec(imin)).getFinalResult();
    assertEquals(9, minIdx);
}
Also used : INDArray(org.nd4j.linalg.api.ndarray.INDArray) IMin(org.nd4j.linalg.api.ops.impl.indexaccum.IMin) IndexAccumulation(org.nd4j.linalg.api.ops.IndexAccumulation) NDArrayIndex.point(org.nd4j.linalg.indexing.NDArrayIndex.point) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest) Test(org.junit.Test)

Example 14 with IndexAccumulation

use of org.nd4j.linalg.api.ops.IndexAccumulation in project nd4j by deeplearning4j.

the class OpExecutionerTestsC method testIMax.

@Test
public void testIMax() {
    INDArray arr = Nd4j.linspace(1, 10, 10);
    IMax imax = new IMax(arr);
    assertEquals(9, ((IndexAccumulation) Nd4j.getExecutioner().exec(imax)).getFinalResult());
    arr.muli(-1);
    imax = new IMax(arr);
    int maxIdx = ((IndexAccumulation) Nd4j.getExecutioner().exec(imax)).getFinalResult();
    assertEquals(0, maxIdx);
}
Also used : INDArray(org.nd4j.linalg.api.ndarray.INDArray) IMax(org.nd4j.linalg.api.ops.impl.indexaccum.IMax) IndexAccumulation(org.nd4j.linalg.api.ops.IndexAccumulation) NDArrayIndex.point(org.nd4j.linalg.indexing.NDArrayIndex.point) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 INDArray (org.nd4j.linalg.api.ndarray.INDArray)14 IndexAccumulation (org.nd4j.linalg.api.ops.IndexAccumulation)14 IMax (org.nd4j.linalg.api.ops.impl.indexaccum.IMax)10 BaseNd4jTest (org.nd4j.linalg.BaseNd4jTest)4 IMin (org.nd4j.linalg.api.ops.impl.indexaccum.IMin)4 NDArrayIndex.point (org.nd4j.linalg.indexing.NDArrayIndex.point)2 File (java.io.File)1 ClassPathResource (org.datavec.api.util.ClassPathResource)1 VocabWord (org.deeplearning4j.models.word2vec.VocabWord)1 LabelAwareFileSentenceIterator (org.deeplearning4j.text.sentenceiterator.labelaware.LabelAwareFileSentenceIterator)1 LabelAwareSentenceIterator (org.deeplearning4j.text.sentenceiterator.labelaware.LabelAwareSentenceIterator)1 DefaultTokenizerFactory (org.deeplearning4j.text.tokenization.tokenizerfactory.DefaultTokenizerFactory)1 TokenizerFactory (org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory)1 DataSet (org.nd4j.linalg.dataset.DataSet)1