public double[,] ToVector(List <HuffmanNode> nodes) { if (nodes == null) { throw new ArgumentNullException(nameof(nodes)); } var oneHot = new double[1, Vocab.GetLengthLeafs()]; foreach (var node in nodes) { var nodeOneHot = MatrixOps.OneHotVector(node.Index, Vocab.GetLengthLeafs()); for (var j = 0; j < nodeOneHot.CountOfColumns(); j++) { oneHot[0, j] += nodeOneHot[0, j]; } } //skip-gram output is actually as many '1's as context words if (IsCbow) { oneHot.ApplyToEach(v => v / nodes.Count); } return(oneHot); }
public double[,] ToVector(HuffmanNode node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } return(MatrixOps.OneHotVector(node.Index, Vocab.GetLengthLeafs())); }
protected internal virtual void InitWiWo(int v = 0) { v = v > 0 ? v : Vocab.GetLengthLeafs(); var n = Size; //https://github.com/ronxin/wevi/blob/master/js/vector_math.js @ function get_random_init_weight(hidden_size) //values are always less than 0.1 double GetInitWeight(double d) => (d - 0.5D) / n; WI = MatrixOps.RandomMatrix(v, n, GetInitWeight); System.Threading.Thread.Sleep(50); WO = MatrixOps.RandomMatrix(n, v, GetInitWeight); }
internal int GetNumberOfTrainWords() { //TODO is this supposed to be all of them? return(Vocab.GetLengthLeafs()); }