Class StaticWord2Vec

    • Method Detail

      • init

        protected void init()
        Init method validates configuration defined using
      • hasWord

        public boolean hasWord​(String word)
        Returns true if the model has this word in the vocab
        Specified by:
        hasWord in interface WordVectors
        Parameters:
        word - the word to test for
        Returns:
        true if the model has the word in the vocab
      • wordsNearestSum

        public Collection<String> wordsNearestSum​(String word,
                                                  int n)
        Get the top n words most similar to the given word PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        wordsNearestSum in interface WordVectors
        Parameters:
        word - the word to compare
        n - the n to get
        Returns:
        the top n words
      • wordsNearestSum

        public Collection<String> wordsNearestSum​(Collection<String> positive,
                                                  Collection<String> negative,
                                                  int top)
        Words nearest based on positive and negative words PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        wordsNearestSum in interface WordVectors
        Parameters:
        positive - the positive words
        negative - the negative words
        top - the top n words
        Returns:
        the words nearest the mean of the words
      • accuracy

        public Map<String,​Double> accuracy​(List<String> questions)
        Accuracy based on questions which are a space separated list of strings where the first word is the query word, the next 2 words are negative, and the last word is the predicted word to be nearest PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        accuracy in interface WordVectors
        Parameters:
        questions - the questions to ask
        Returns:
        the accuracy based on these questions
      • similarWordsInVocabTo

        public List<String> similarWordsInVocabTo​(String word,
                                                  double accuracy)
        Find all words with a similar characters in the vocab PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        similarWordsInVocabTo in interface WordVectors
        Parameters:
        word - the word to compare
        accuracy - the accuracy: 0 to 1
        Returns:
        the list of words that are similar in the vocab
      • getWordVector

        public double[] getWordVector​(String word)
        Get the word vector for a given matrix
        Specified by:
        getWordVector in interface WordVectors
        Parameters:
        word - the word to get the matrix for
        Returns:
        the ndarray for this word
      • getWordVectorMatrixNormalized

        public org.nd4j.linalg.api.ndarray.INDArray getWordVectorMatrixNormalized​(String word)
        Returns the word vector divided by the norm2 of the array
        Specified by:
        getWordVectorMatrixNormalized in interface WordVectors
        Parameters:
        word - the word to get the matrix for
        Returns:
        the looked up matrix
      • getWordVectorMatrix

        public org.nd4j.linalg.api.ndarray.INDArray getWordVectorMatrix​(String word)
        Get the word vector for a given matrix
        Specified by:
        getWordVectorMatrix in interface WordVectors
        Parameters:
        word - the word to get the matrix for
        Returns:
        the ndarray for this word
      • getWordVectors

        public org.nd4j.linalg.api.ndarray.INDArray getWordVectors​(Collection<String> labels)
        This method returns 2D array, where each row represents corresponding word/label
        Specified by:
        getWordVectors in interface WordVectors
        Parameters:
        labels -
        Returns:
      • getWordVectorsMean

        public org.nd4j.linalg.api.ndarray.INDArray getWordVectorsMean​(Collection<String> labels)
        This method returns mean vector, built from words/labels passed in
        Specified by:
        getWordVectorsMean in interface WordVectors
        Parameters:
        labels -
        Returns:
      • wordsNearest

        public Collection<String> wordsNearest​(Collection<String> positive,
                                               Collection<String> negative,
                                               int top)
        Words nearest based on positive and negative words PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        wordsNearest in interface WordVectors
        Parameters:
        positive - the positive words
        negative - the negative words
        top - the top n words
        Returns:
        the words nearest the mean of the words
      • wordsNearest

        public Collection<String> wordsNearest​(String word,
                                               int n)
        Get the top n words most similar to the given word PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        wordsNearest in interface WordVectors
        Parameters:
        word - the word to compare
        n - the n to get
        Returns:
        the top n words
      • similarity

        public double similarity​(String label1,
                                 String label2)
        Returns the similarity of 2 words
        Specified by:
        similarity in interface WordVectors
        Parameters:
        label1 - the first word
        label2 - the second word
        Returns:
        a normalized similarity (cosine similarity)
      • lookupTable

        public WeightLookupTable lookupTable()
        Lookup table for the vectors PLEASE NOTE: This method is not available in this implementation.
        Specified by:
        lookupTable in interface WordVectors
        Returns:
      • setModelUtils

        public void setModelUtils​(ModelUtils utils)
        Specifies ModelUtils to be used to access model PLEASE NOTE: This method has no effect in this implementation.
        Specified by:
        setModelUtils in interface WordVectors
        Parameters:
        utils -
      • loadWeightsInto

        public void loadWeightsInto​(org.nd4j.linalg.api.ndarray.INDArray array)
        Specified by:
        loadWeightsInto in interface org.deeplearning4j.nn.weights.embeddings.EmbeddingInitializer
      • vocabSize

        public long vocabSize()
        Specified by:
        vocabSize in interface org.deeplearning4j.nn.weights.embeddings.EmbeddingInitializer
      • vectorSize

        public int vectorSize()
        Specified by:
        vectorSize in interface org.deeplearning4j.nn.weights.embeddings.EmbeddingInitializer
      • jsonSerializable

        public boolean jsonSerializable()
        Specified by:
        jsonSerializable in interface org.deeplearning4j.nn.weights.embeddings.EmbeddingInitializer
      • outOfVocabularySupported

        public boolean outOfVocabularySupported()
        Description copied from interface: WordVectors
        Does implementation vectorize words absent in vocabulary
        Specified by:
        outOfVocabularySupported in interface WordVectors
        Returns:
        boolean