public EmbeddingView() { InitializeComponent(); WindowState = FormWindowState.Maximized; embedding = new Embedding(); embedding.Train("corpus.db"); }
/// <summary> /// Weighted average of all embeddings /// </summary> /// <param name="document">List of words</param> /// <returns>value</returns> public Vector <double> WeightedAverage(List <string> document) { Vector <double> avg = Vectors.Dense(Embedding.EmbeddingSize); foreach (string word in document) { double weight = Tf_Idf(word, document); avg += Embedding.Lookup(word) * weight; } return(avg / document.Count); }
public AverageEmbedding() { CorpusSize = 0; CorpusAppearances = new Dictionary <string, int>(); Embedding = new Embedding(); Embedding.Load("embedding.db"); W1 = Matrices.Random(Embedding.EmbeddingSize, HiddenSize).Map(p => p * 0.01); B1 = Vectors.Dense(HiddenSize); W2 = Matrices.Random(HiddenSize, Classes).Map(p => p * 0.01); B2 = Vectors.Dense(Classes); }