Search in sources :

Example 1 with MojoModel

use of hex.genmodel.MojoModel in project h2o-3 by h2oai.

the class Word2VecMojoModelTest method testTransform0.

@Test
public void testTransform0() throws Exception {
    MojoModel mojo = Word2VecMojoReader.readFrom(new Word2VecMojoModelTest.ClasspathReaderBackend());
    assertTrue(mojo instanceof WordEmbeddingModel);
    WordEmbeddingModel m = (WordEmbeddingModel) mojo;
    assertEquals(3, m.getVecSize());
    assertArrayEquals(new float[] { 0.0f, 1.0f, 0.2f }, m.transform0("a", new float[3]), 0.0001f);
    assertArrayEquals(new float[] { 1.0f, 0.0f, 0.8f }, m.transform0("b", new float[3]), 0.0001f);
    // out-of-dictionary word
    assertNull(m.transform0("c", new float[3]));
}
Also used : MojoModel(hex.genmodel.MojoModel) Test(org.junit.Test)

Aggregations

MojoModel (hex.genmodel.MojoModel)1 Test (org.junit.Test)1