Codota Logo
SpTree
Code IndexAdd Codota to your IDE (free)

How to use
SpTree
in
org.deeplearning4j.clustering.sptree

Best Java code snippets using org.deeplearning4j.clustering.sptree.SpTree (Showing top 12 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: org.deeplearning4j/nearestneighbor-core

/**
 * The depth of the node
 * @return the depth of the node
 */
public int depth() {
  if (isLeaf())
    return 1;
  int depth = 1;
  int maxChildDepth = 0;
  for (int i = 0; i < numChildren; i++) {
    maxChildDepth = Math.max(maxChildDepth, children[0].depth());
  }
  return depth + maxChildDepth;
}
origin: org.deeplearning4j/nearestneighbor-core

public SpTree(SpTree parent, INDArray data, INDArray corner, INDArray width, Set<INDArray> indices,
        String similarityFunction) {
  init(parent, data, corner, width, indices, similarityFunction);
}
origin: org.deeplearning4j/nearestneighbor-core

private void fill(int n) {
  if (indices.isEmpty() && parent == null)
    for (int i = 0; i < n; i++) {
      log.trace("Inserted " + i);
      insert(i);
    }
  else
    log.warn("Called fill already");
}
origin: org.deeplearning4j/nearestneighbor-core

/**
 * Verifies the structure of the tree (does bounds checking on each node)
 * @return true if the structure of the tree
 * is correct.
 */
public boolean isCorrect() {
  for (int n = 0; n < size; n++) {
    INDArray point = data.slice(index[n]);
    if (!boundary.contains(point))
      return false;
  }
  if (!isLeaf()) {
    boolean correct = true;
    for (int i = 0; i < numChildren; i++)
      correct = correct && children[i].isCorrect();
    return correct;
  }
  return true;
}
origin: org.deeplearning4j/deeplearning4j-tsne

@Override
public Gradient gradient() {
  MemoryWorkspace workspace =
      workspaceMode == WorkspaceMode.NONE ? new DummyWorkspace()
          : Nd4j.getWorkspaceManager().getWorkspaceForCurrentThread(
          workspaceConfigurationExternal,
          workspaceExternal);
  try (MemoryWorkspace ws = workspace.notifyScopeEntered()) {
    if (yIncs == null)
      yIncs = zeros(Y.shape());
    if (gains == null)
      gains = ones(Y.shape());
    AtomicDouble sumQ = new AtomicDouble(0);
    /* Calculate gradient based on barnes hut approximation with positive and negative forces */
    INDArray posF = Nd4j.create(Y.shape());
    INDArray negF = Nd4j.create(Y.shape());
    if (tree == null) {
      tree = new SpTree(Y);
      tree.setWorkspaceMode(workspaceMode);
    }
    tree.computeEdgeForces(rows, cols, vals, N, posF);
    for (int n = 0; n < N; n++)
      tree.computeNonEdgeForces(n, theta, negF.slice(n), sumQ);
    INDArray dC = posF.subi(negF.divi(sumQ));
    Gradient ret = new DefaultGradient();
    ret.gradientForVariable().put(Y_GRAD, dC);
    return ret;
  }
}
origin: org.deeplearning4j/deeplearning4j-core

@Override
public Gradient gradient() {
  if (yIncs == null)
    yIncs = zeros(Y.shape());
  if (gains == null)
    gains = ones(Y.shape());
  AtomicDouble sumQ = new AtomicDouble(0);
  /* Calculate gradient based on barnes hut approximation with positive and negative forces */
  INDArray posF = Nd4j.create(Y.shape());
  INDArray negF = Nd4j.create(Y.shape());
  if (tree == null)
    tree = new SpTree(Y);
  tree.computeEdgeForces(rows, cols, vals, N, posF);
  for (int n = 0; n < N; n++)
    tree.computeNonEdgeForces(n, theta, negF.slice(n), sumQ);
  INDArray dC = posF.subi(negF.divi(sumQ));
  Gradient ret = new DefaultGradient();
  ret.gradientForVariable().put(Y_GRAD, dC);
  return ret;
}
origin: org.deeplearning4j/nearestneighbor-core

if (cumSize == 0 || (isLeaf() && size == 1 && index[0] == pointIndex))
  return;
if (isLeaf() || maxWidth / FastMath.sqrt(D) < theta) {
    children[i].computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
origin: org.deeplearning4j/deeplearning4j-core

@Override
public double score() {
  // Get estimate of normalization term
  INDArray buff = Nd4j.create(numDimensions);
  AtomicDouble sum_Q = new AtomicDouble(0.0);
  for (int n = 0; n < N; n++)
    tree.computeNonEdgeForces(n, theta, buff, sum_Q);
  // Loop over all edges to compute t-SNE error
  double C = .0;
  INDArray linear = Y;
  for (int n = 0; n < N; n++) {
    int begin = rows.getInt(n);
    int end = rows.getInt(n + 1);
    int ind1 = n;
    for (int i = begin; i < end; i++) {
      int ind2 = cols.getInt(i);
      buff.assign(linear.slice(ind1));
      buff.subi(linear.slice(ind2));
      double Q = pow(buff, 2).sum(Integer.MAX_VALUE).getDouble(0);
      Q = (1.0 / (1.0 + Q)) / sum_Q.doubleValue();
      C += vals.getDouble(i) * FastMath.log(vals.getDouble(i) + Nd4j.EPS_THRESHOLD)
              / (Q + Nd4j.EPS_THRESHOLD);
    }
  }
  return C;
}
origin: org.deeplearning4j/nearestneighbor-core

children[i] = new SpTree(this, data, newCorner, newWidth, indices);
for (int j = 0; j < this.numChildren; j++)
  if (!success)
    success = children[j].insert(index[i]);
origin: org.deeplearning4j/nearestneighbor-core

private boolean insert(int index) {
  INDArray point = data.slice(index);
  if (!boundary.contains(point))
    return false;
  cumSize++;
  double mult1 = (double) (cumSize - 1) / (double) cumSize;
  double mult2 = 1.0 / (double) cumSize;
  centerOfMass.muli(mult1);
  centerOfMass.addi(point.mul(mult2));
  // If there is space in this quad tree and it is a leaf, add the object here
  if (isLeaf() && size < nodeCapacity) {
    this.index[size] = index;
    indices.add(point);
    size++;
    return true;
  }
  for (int i = 0; i < size; i++) {
    INDArray compPoint = data.slice(this.index[i]);
    if (compPoint.equals(point))
      return true;
  }
  if (isLeaf())
    subDivide();
  // Find out where the point can be inserted
  for (int i = 0; i < numChildren; i++) {
    if (children[i].insert(index))
      return true;
  }
  throw new IllegalStateException("Shouldn't reach this state");
}
origin: org.deeplearning4j/nearestneighbor-core

public SpTree(INDArray data, Set<INDArray> indices, String similarityFunction) {
  this.indices = indices;
  this.N = data.rows();
  this.D = data.columns();
  this.similarityFunction = similarityFunction;
  INDArray meanY = data.mean(0);
  INDArray minY = data.min(0);
  INDArray maxY = data.max(0);
  INDArray width = Nd4j.create(meanY.shape());
  for (int i = 0; i < width.length(); i++) {
    width.putScalar(i, FastMath.max(maxY.getDouble(i) - meanY.getDouble(i),
            meanY.getDouble(i) - minY.getDouble(i) + Nd4j.EPS_THRESHOLD));
  }
  init(null, data, meanY, width, indices, similarityFunction);
  fill(N);
}
origin: org.deeplearning4j/deeplearning4j-tsne

AtomicDouble sum_Q = new AtomicDouble(0.0);
for (int n = 0; n < N; n++)
  tree.computeNonEdgeForces(n, theta, buff, sum_Q);
org.deeplearning4j.clustering.sptreeSpTree

Most used methods

  • <init>
  • computeNonEdgeForces
    Compute non edge forces using barnes hut
  • computeEdgeForces
    Compute edge forces using barns hut
  • depth
    The depth of the node
  • fill
  • init
  • insert
  • isCorrect
    Verifies the structure of the tree (does bounds checking on each node)
  • isLeaf
  • setWorkspaceMode
  • subDivide
    Subdivide the node in to 4 children
  • subDivide

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now