Ejemplo n.º 1
0
        private IOPair <float[]> GetSequenceData(int index)
        {
            string filename = Vocab[index];
            int    length   = filename.Length;

            float[] input  = new float[Vocab.CharCount * length];
            float[] output = new float[Vocab.CharCount * length];

            for (int i = 0; i < length; i++)
            {
                input[(Vocab.CharCount * i) + Vocab.Encode(filename[i])] = 1;
            }

            // copy the input sequence shifted by one
            // space fill the final output char
            Array.Copy(input, 1, output, 0, input.Length - 1);
            output[output.Length - Vocab.CharCount + Vocab.Encode(' ')] = 1;

            return(new IOPair <float[]>(input, output));
        }
        private void Load(string sSrcModel, string sTgtModel, string sVocab, int ngram)
        {
            m_SrcModel.LoadModelV0(sSrcModel, LoadModelInBackCompatibleMode);
            m_TgtModel.LoadModelV0(sTgtModel, LoadModelInBackCompatibleMode);

            m_V = new Vocab(false);
            using (StreamReader sr = new StreamReader(sVocab))
            {
                string sLine = "";
                while ((sLine = sr.ReadLine()) != null)
                {
                    string[] rgs = sLine.Trim().Split('\t');
                    m_V.Encode(rgs[0]);
                }
            }
            m_V.Lock();
            m_LetterNgram = ngram;
        }