@Test public void testRPTree() throws Exception { DataSetIterator mnist = new MnistDataSetIterator(150,150); RPTree rpTree = new RPTree(784,50); DataSet d = mnist.next(); NormalizerStandardize normalizerStandardize = new NormalizerStandardize(); normalizerStandardize.fit(d); normalizerStandardize.transform(d.getFeatures()); INDArray data = d.getFeatures(); rpTree.buildTree(data); assertEquals(4,rpTree.getLeaves().size()); assertEquals(0,rpTree.getRoot().getDepth()); List<Integer> candidates = rpTree.getCandidates(data.getRow(0)); assertFalse(candidates.isEmpty()); assertEquals(10,rpTree.query(data.slice(0),10).length()); System.out.println(candidates.size()); rpTree.addNodeAtIndex(150,data.getRow(0)); }
@Builder public RPTree(int dim, int maxSize,String similarityFunction) { this.dim = dim; this.maxSize = maxSize; rpHyperPlanes = new RPHyperPlanes(dim); root = new RPNode(this,0); this.similarityFunction = similarityFunction; workspaceConfiguration = WorkspaceConfiguration.builder().cyclesBeforeInitialization(1) .policyAllocation(AllocationPolicy.STRICT).policyLearning(LearningPolicy.FIRST_LOOP) .policyMirroring(MirroringPolicy.FULL).policyReset(ResetPolicy.BLOCK_LEFT) .policySpill(SpillPolicy.REALLOCATE).build(); }
RPTree { @Builder public RPTree(int dim, int maxSize,String similarityFunction) { this.dim = dim; this.maxSize = maxSize; rpHyperPlanes = new RPHyperPlanes(dim); root = new RPNode(this,0); this.similarityFunction = similarityFunction; workspaceConfiguration = WorkspaceConfiguration.builder().cyclesBeforeInitialization(1) .policyAllocation(AllocationPolicy.STRICT).policyLearning(LearningPolicy.FIRST_LOOP) .policyMirroring(MirroringPolicy.FULL).policyReset(ResetPolicy.BLOCK_LEFT) .policySpill(SpillPolicy.REALLOCATE).build(); } }
RPTree { @Builder public RPTree(int dim, int maxSize,String similarityFunction) { this.dim = dim; this.maxSize = maxSize; rpHyperPlanes = new RPHyperPlanes(dim); root = new RPNode(this,0); this.similarityFunction = similarityFunction; workspaceConfiguration = WorkspaceConfiguration.builder().cyclesBeforeInitialization(1) .policyAllocation(AllocationPolicy.STRICT).policyLearning(LearningPolicy.FIRST_LOOP) .policyMirroring(MirroringPolicy.FULL).policyReset(ResetPolicy.BLOCK_LEFT) .policySpill(SpillPolicy.REALLOCATE).build(); } @Builder  RPTree(int dim, int maxSize,String similarityFunction);  RPTree(int dim, int maxSize); }
RPTree { @Builder public RPTree(int dim, int maxSize,String similarityFunction) { this.dim = dim; this.maxSize = maxSize; rpHyperPlanes = new RPHyperPlanes(dim); root = new RPNode(this,0); this.similarityFunction = similarityFunction; workspaceConfiguration = WorkspaceConfiguration.builder().cyclesBeforeInitialization(1) .policyAllocation(AllocationPolicy.STRICT).policyLearning(LearningPolicy.FIRST_LOOP) .policyMirroring(MirroringPolicy.FULL).policyReset(ResetPolicy.BLOCK_LEFT) .policySpill(SpillPolicy.REALLOCATE).build(); } @Builder  RPTree(int dim, int maxSize,String similarityFunction);  RPTree(int dim, int maxSize); void buildTree(INDArray x); void addNodeAtIndex(int idx,INDArray toAdd); List<RPNode> getLeaves(); List<Pair<Double, Integer>> queryWithDistances(INDArray query, int numResults); INDArray query(INDArray query,int numResults); List<Integer> getCandidates(INDArray target); }
RPTree { @Builder public RPTree(int dim, int maxSize,String similarityFunction) { this.dim = dim; this.maxSize = maxSize; rpHyperPlanes = new RPHyperPlanes(dim); root = new RPNode(this,0); this.similarityFunction = similarityFunction; workspaceConfiguration = WorkspaceConfiguration.builder().cyclesBeforeInitialization(1) .policyAllocation(AllocationPolicy.STRICT).policyLearning(LearningPolicy.FIRST_LOOP) .policyMirroring(MirroringPolicy.FULL).policyReset(ResetPolicy.BLOCK_LEFT) .policySpill(SpillPolicy.REALLOCATE).build(); } @Builder  RPTree(int dim, int maxSize,String similarityFunction);  RPTree(int dim, int maxSize); void buildTree(INDArray x); void addNodeAtIndex(int idx,INDArray toAdd); List<RPNode> getLeaves(); List<Pair<Double, Integer>> queryWithDistances(INDArray query, int numResults); INDArray query(INDArray query,int numResults); List<Integer> getCandidates(INDArray target);  }