@Test public void testHashDimsMultiple(){ INDArray data = Nd4j.ones(1, intDimensions); assertArrayEquals(new long[]{1, hashLength}, rpLSH.hash(data).shape()); data = Nd4j.ones(100, intDimensions); assertArrayEquals(new long[]{100, hashLength}, rpLSH.hash(data).shape()); }
public INDArray hash(INDArray data) { if (data.shape()[1] != inDimension){ throw new ND4JIllegalStateException( String.format("Invalid shape: Requested INDArray shape %s, this table expects dimension %d", Arrays.toString(data.shape()), inDimension)); } INDArray projected = data.mmul(randomProjection); INDArray res = Nd4j.getExecutioner().exec(new Sign(projected)); return res; }
RandomProjectionLSH implements LSH { public INDArray hash(INDArray data) { if (data.shape()[1] != inDimension){ throw new ND4JIllegalStateException( String.format("Invalid shape: Requested INDArray shape %s, this table expects dimension %d", Arrays.toString(data.shape()), inDimension)); } INDArray projected = data.mmul(randomProjection); INDArray res = Nd4j.getExecutioner().exec(new Sign(projected)); return res; } }
RandomProjectionLSH implements LSH { public INDArray hash(INDArray data) { if (data.shape()[1] != inDimension){ throw new ND4JIllegalStateException( String.format("Invalid shape: Requested INDArray shape %s, this table expects dimension %d", Arrays.toString(data.shape()), inDimension)); } INDArray projected = data.mmul(randomProjection); INDArray res = Nd4j.getExecutioner().exec(new Sign(projected)); return res; } RandomProjectionLSH(int hashLength, int numTables, int inDimension, double radius);  RandomProjectionLSH(int hashLength, int numTables, int inDimension, double radius, Random rng); }
RandomProjectionLSH implements LSH { public INDArray hash(INDArray data) { if (data.shape()[1] != inDimension){ throw new ND4JIllegalStateException( String.format("Invalid shape: Requested INDArray shape %s, this table expects dimension %d", Arrays.toString(data.shape()), inDimension)); } INDArray projected = data.mmul(randomProjection); INDArray res = Nd4j.getExecutioner().exec(new Sign(projected)); return res; } RandomProjectionLSH(int hashLength, int numTables, int inDimension, double radius);  RandomProjectionLSH(int hashLength, int numTables, int inDimension, double radius, Random rng); @Override String getDistanceMeasure(); INDArray entropy(INDArray data); INDArray hash(INDArray data); @Override void makeIndex(INDArray data); @Override INDArray bucket(INDArray query); @Override INDArray search(INDArray query, double maxRange); @Override INDArray search(INDArray query, int k); }
RandomProjectionLSH implements LSH { public INDArray hash(INDArray data) { if (data.shape()[1] != inDimension){ throw new ND4JIllegalStateException( String.format("Invalid shape: Requested INDArray shape %s, this table expects dimension %d", Arrays.toString(data.shape()), inDimension)); } INDArray projected = data.mmul(randomProjection); INDArray res = Nd4j.getExecutioner().exec(new Sign(projected)); return res; } RandomProjectionLSH(int hashLength, int numTables, int inDimension, double radius);  RandomProjectionLSH(int hashLength, int numTables, int inDimension, double radius, Random rng); @Override String getDistanceMeasure(); INDArray entropy(INDArray data); INDArray hash(INDArray data); @Override void makeIndex(INDArray data); @Override INDArray bucket(INDArray query); @Override INDArray search(INDArray query, double maxRange); @Override INDArray search(INDArray query, int k);  }