Exemplo n.º 1
0
    public IEnumerator UpdateProgress()
    {
        if (!manager)
        {
            yield return(null);
        }

        string reg   = @"\d+/" + numTraining.ToString();
        Regex  regex = new Regex(@reg);

        FileStream   logFileStream = new FileStream(manager.logpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        StreamReader logFileReader = new StreamReader(logFileStream);

        bool bLocalWaiting = true;
        int  epochNum      = 1;

        while (bIsCalculating && bLocalWaiting)
        {
            if (!logFileReader.EndOfStream)
            {
                string line = logFileReader.ReadLine();

                if (line.Length > 4 && line.Substring(0, 4) == numTraining.ToString())
                {
                    epochNum++;
                }
                else if (line.Contains("Test"))
                {
                    manager.UpdateProgress("Writing activation layers...");
                    bLocalWaiting = false; // Don't read anymore lines
                }
                else
                {
                    Match match = regex.Match(line);
                    if (match.Success)
                    {
                        // manager.UpdateProgress("Epoch #" + (3-numEpochs) + ": " + match.Value + " complete.");
                        manager.UpdateProgress("Epoch #" + epochNum + " " + match.Value + " complete.");
                    }
                }
            }

            yield return(new WaitForSeconds(0.12f));
        }

        // Clean up
        logFileReader.Close();
        logFileStream.Close();
    }
Exemplo n.º 2
0
    public IEnumerator UpdateProgress()
    {
        if (!manager)
        {
            yield return(null);
        }

        Regex regex = new Regex(@"\d+/7000");

        FileStream   logFileStream = new FileStream(manager.logpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        StreamReader logFileReader = new StreamReader(logFileStream);

        bool bLocalWaiting = true;

        while (bIsCalculating && bLocalWaiting)
        {
            if (!logFileReader.EndOfStream)
            {
                string line = logFileReader.ReadLine();

                if (line.Length > 4 && line.Substring(0, 4) == "7000")
                {
                    manager.UpdateProgress("Writing activation layers...");
                    bLocalWaiting = false; // Don't read anymore lines
                }
                else
                {
                    Match match = regex.Match(line);
                    if (match.Success)
                    {
                        manager.UpdateProgress(match.Value + " complete.");
                    }
                }
            }

            yield return(new WaitForSeconds(0.12f));
        }

        // Clean up
        logFileReader.Close();
        logFileStream.Close();
    }