【问题标题】:CNTK CMD RedirectStandardOutput = true not workingCNTK CMD RedirectStandardOutput = true 不工作
【发布时间】:2019-05-10 23:28:24
【问题描述】:

Microsoft 已经放弃了用于 ML.NET(糟糕的产品)和 ONNX(尚未研究)的 CNTK。

CNTK,微软开源的最佳产品,但有很多错误和零支持,很遗憾!

我不情愿地向 Stackoverflow 社区寻求潜在的解决方案。

string filepath = @"<My big long Path>\";
string filename = Path.Combine(filepath, @"Data\SLUHandsOn.cntk");

if (!File.Exists(filename))
    ProcessOutputData("File does not exist!");

Process process = new Process();

process.StartInfo.FileName = "CMD";
process.StartInfo.WorkingDirectory = filepath;
process.StartInfo.Arguments = "/c cntk configFile=" + "\"" + filename + "\"";

process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;

process.Start();

process.OutputDataReceived += new DataReceivedEventHandler((x, y) =>
{
    ProcessOutputData(y.Data);
});

process.BeginOutputReadLine();

方法ProcessOutputData也很简单:

private void ProcessOutputData(string text)
{

    if (InvokeRequired)
    {
        Invoke(new MethodInvoker(() => { ProcessOutputData(text); }));
    }
    else
    {
        // Output Data:
        richTextBox1.AppendText(text + Environment.NewLine);
    }
}

不用说,CNTK 似乎没有输出数据。我尝试使用 CMD.exe 运行 CNTK,并使用 Visual Studio Tools for AI Redistributable 中的 CNTK.exe。

同样,我面临的问题是没有RedirectStandardOutput 数据。

谢谢。

回答感谢:MarcelGrommer - 谢谢!

process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
{

    ProcessOutputData(e.Data);
});

// Asynchronously read the standard Error of the spawned process.
process.BeginErrorReadLine();

【问题讨论】:

    标签: c# cntk


    【解决方案1】:

    您必须使用 RedirectStandardError 通道。 CNTK 计算网络误差,因此数据来自 StandardError 通道。它有效。

    processCNTK.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
    {
                string outFromCNTK = e.Data;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 2016-04-09
      • 2019-05-02
      • 2018-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多