/** * <summary>Constructor for the {@link Iteration} class. Get corpus and parameter as input, sets the corresponding * parameters.</summary> * <param name="corpus">Corpus used to train word vectors using Word2Vec algorithm.</param> * <param name="wordToVecParameter">Parameters of the Word2Vec algorithm.</param> */ public Iteration(Corpus.Corpus corpus, WordToVecParameter wordToVecParameter) { this.corpus = corpus; this._wordToVecParameter = wordToVecParameter; _startingAlpha = wordToVecParameter.GetAlpha(); _alpha = wordToVecParameter.GetAlpha(); }
/** * <summary>Constructor for the {@link NeuralNetwork} class. Gets corpus and network parameters as input and sets the * corresponding parameters first. After that, initializes the network with random weights between -0.5 and 0.5. * Constructs vector update matrix and prepares the exp table.</summary> * <param name="corpus">Corpus used to train word vectors using Word2Vec algorithm.</param> * <param name="parameter">Parameters of the Word2Vec algorithm.</param> */ public NeuralNetwork(Corpus.Corpus corpus, WordToVecParameter parameter) { this._vocabulary = new Vocabulary(corpus); this._parameter = parameter; this._corpus = corpus; _wordVectors = new Matrix(_vocabulary.Size(), parameter.GetLayerSize(), -0.5, 0.5, new Random()); _wordVectorUpdate = new Matrix(_vocabulary.Size(), parameter.GetLayerSize()); PrepareExpTable(); }