@Test public void testEntropyDims(){ assertArrayEquals(new long[]{numTables, intDimensions}, rpLSH.entropy(e1).shape()); }
public INDArray entropy(INDArray data){ INDArray data2 = Nd4j.getExecutioner().exec(new GaussianDistribution(Nd4j.create(numTables, inDimension), radius)); INDArray norms = Nd4j.norm2(data2.dup(), -1); Preconditions.checkState(norms.rank() == 1 && norms.size(0) == numTables, "Expected norm2 to have shape [%s], is %ndShape", norms.size(0), norms); data2.diviColumnVector(norms); data2.addiRowVector(data); return data2; }
RandomProjectionLSH implements LSH { public INDArray entropy(INDArray data){ INDArray data2 = Nd4j.getExecutioner().exec(new GaussianDistribution(Nd4j.create(numTables, inDimension), radius)); INDArray norms = Nd4j.norm2(data2.dup(), -1); Preconditions.checkState(norms.rank() == 1 && norms.size(0) == numTables, "Expected norm2 to have shape [%s], is %ndShape", norms.size(0), norms); data2.diviColumnVector(norms); data2.addiRowVector(data); return data2; } }
RandomProjectionLSH implements LSH { public INDArray entropy(INDArray data){ INDArray data2 = Nd4j.getExecutioner().exec(new GaussianDistribution(Nd4j.create(numTables, inDimension), radius)); INDArray norms = Nd4j.norm2(data2.dup(), -1); Preconditions.checkState(norms.rank() == 1 && norms.size(0) == numTables, "Expected norm2 to have shape [%s], is %ndShape", norms.size(0), norms); data2.diviColumnVector(norms); data2.addiRowVector(data); return data2; } 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 entropy(INDArray data){ INDArray data2 = Nd4j.getExecutioner().exec(new GaussianDistribution(Nd4j.create(numTables, inDimension), radius)); INDArray norms = Nd4j.norm2(data2.dup(), -1); Preconditions.checkState(norms.rank() == 1 && norms.size(0) == numTables, "Expected norm2 to have shape [%s], is %ndShape", norms.size(0), norms); data2.diviColumnVector(norms); data2.addiRowVector(data); return data2; } 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 entropy(INDArray data){ INDArray data2 = Nd4j.getExecutioner().exec(new GaussianDistribution(Nd4j.create(numTables, inDimension), radius)); INDArray norms = Nd4j.norm2(data2.dup(), -1); Preconditions.checkState(norms.rank() == 1 && norms.size(0) == numTables, "Expected norm2 to have shape [%s], is %ndShape", norms.size(0), norms); data2.diviColumnVector(norms); data2.addiRowVector(data); return data2; } 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);  }