Пример #1
0
        /// <summary>
        /// Uses the path variable to parametrise a HMM for each file at that path (each file contains the parameters of a trained HMM)
        /// </summary>
        private void loadParameters()
        {
            string parametersFile = dataPath + "Parameters/" + name + "/";
            string[] fileNames = Directory.GetFiles(parametersFile);

            D_HMM dhmm;

            foreach (string fileName in fileNames)
            {
                string hmmname = fileName.Split('.')[0];
                hmmname = hmmname.Split('/').Last();

                dhmm = new D_HMM(hmmname, parametersFile);
                jointHMMs.Add(hmmname, dhmm);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns a newly initialized HMM. This method is where we encode our initial markov chain topology
        /// </summary>
        /// <param name="name">The name of the HMM (the sign corresponding to this HMM)</param>
        /// <param name="centroids">The centroids of the clusters of the training data, used to convert input streams to HMM  symbol streams</param>
        /// <returns>a new HMM which is initialized with a predetermined topology and ready to be trained</returns>
        private D_HMM initializeNewHMM(string name, double[][] centroids)
        {
            //Create A
            double[,] A = new double[12, 12];
            for (int i = 0; i < 12; i++)
            {
                A[i, i] = 0.5;
                if (i < 11)
                {
                    A[i, i + 1] = 0.5;
                }
                A[11, 11] = 1;
            }
            //Create B
            double[,] B = new double[12, centroids.Length+1];

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < centroids.Length+1; j++)
                {
                    B[i, j] = (1.0 / (centroids.Length+1));
                }
            }
            //Pi
            double[] pi = new double[12];
            pi[0] = 1;

            D_HMM hmm = new D_HMM(pi, A, B, centroids, name);
            return hmm;
        }