Examples of DenseVector


Examples of edu.ucla.sspace.vector.DenseVector

     * @return The semantic vector generated from the circular convolution.
     */
    private DoubleVector groupConvolution(Queue<String> prevWords,
                                          Queue<String> nextWords) {
        // Generate an empty DoubleVector to hold the convolution.
        DoubleVector result = new DenseVector(indexVectorSize);

        // Do the convolutions starting at index 0.
        String prevWord = prevWords.peek();
        DoubleVector tempConvolution;
        if (!prevWord.equals(IteratorFactory.EMPTY_TOKEN)) {
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

     * @param orderVector The ordering of values to be used.
     *
     * @return The shuffled version of {@code data}.
     */
    private DoubleVector changeVector(DoubleVector data, int[] orderVector) {
        DoubleVector result = new DenseVector(indexVectorSize);
        for (int i = 0; i < indexVectorSize; i++)
            result.set(i, data.get(orderVector[i]));
        return result;
    }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

        // Copy out the vector itself so that we don't retain a reference to the
        // matrix as a result of its getRowVector call, which isn't guaranteed
        // to return a copy.
        int cols = result.columns();
        DoubleVector projected = new DenseVector(result.columns());
        for (int i = 0; i < cols; ++i)
            projected.set(i, result.get(0, i));
        return projected;
    }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

                // add up all of the semantics for this time step's semantics
                for (Map.Entry<Integer,Double> e : vectors.entrySet()) {
                    semantics[e.getKey().intValue()] += e.getValue().intValue();
                }
            }
            return new DenseVector(semantics);
        }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

    public SortedMultiMap<Double,String> getMostSimilar(
             Set<String> terms, int numberOfSimilarWords) {
        if (terms.isEmpty())
            return null;
        // Compute the mean vector for all the terms
        DoubleVector mean = new DenseVector(sspace.getVectorLength());
        int found = 0;
        for (String term : terms) {
            Vector v = sspace.getVector(term);
            if (v == null)
                info(LOGGER, "No vector for term " + term);
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

    /**
     * {@inheritDoc}
     */
    public DoubleVector getColumnVector(int column) {
        DenseVector col = new DenseVector(rows);
        for (int r = 0; r < rows; ++r)
            col.set(r, get(r, column));
        return col;
    }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

   
    /**
     * {@inheritDoc}
     */
    public DoubleVector getRowVector(int row) {
        DenseVector rowVec = new DenseVector(columns);
        for (int c = 0; c < columns; ++c)
            rowVec.set(c, get(row, c));
        return rowVec;
    }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

    /**
     * Generate a new random vector using a guassian distribution for each
     * value.
     */
    public synchronized DoubleVector generate() {
        DoubleVector termVector = new DenseVector(indexVectorLength);
        for (int i = 0; i < indexVectorLength; i++)
            termVector.set(i, mean + (randomGenerator.nextGaussian() * stdev));
        return termVector;
    }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

     * Generates a simple random vector.
     */
    private static DoubleVector generateInitialVector(int length,
                                                      double mean,
                                                      double std) {
        DoubleVector vector = new DenseVector(length);
        for (int i = 0; i < length; ++i) {
            double v = RANDOM.nextGaussian();
            v = std * v + mean;
            vector.set(i, v);
        }
        return vector;
    }
View Full Code Here

Examples of edu.ucla.sspace.vector.DenseVector

                        numChanged = 0;
                        // Recompute the new centroids each time
                        DoubleVector[] updatedCentroids =
                            new DoubleVector[numClusters];
                        for (i = 0; i < updatedCentroids.length; ++i)
                            updatedCentroids[i] = new DenseVector(cols);
                        int[] updatedCentroidSizes = new int[numClusters];

                        double similaritySum = 0;
                       
                        // For each CandidateCluster find the most similar centroid
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.