【问题标题】:CNTKLibrary-2.0 "System.AccessViolationException: Attempted to read or write protected memory. "CNTKLibrary-2.0 "System.AccessViolationException: 试图读取或写入受保护的内存。"
【发布时间】:2017-01-18 18:55:05
【问题描述】:

我正在按照 CNTKLibrary-2.0 示例编写一个简单的案例来检查 minibatch 版本的评估。代码如下所示。但是当我调用“评估”函数时,我得到了访问冲突异常。有关此类异常的任何见解。

const string outputName = "r1";
const string inputName = "qu1fea";
var inputDataMap = new Dictionary<Variable, Value>();

// Load the model.
Function modelFunc = Function.LoadModel("D:/deep_cross/ModelEvaluation_cpp/models/dfsr.cn", device);
Console.WriteLine(modelFunc.Outputs.Count);
for (int i = 0; i < modelFunc.Outputs.Count; i++)
{
    Console.WriteLine(modelFunc.Outputs[i].GetName());
}

// Get output variable based on name
Variable outputVar = modelFunc.Outputs.Where(variable => string.Equals(variable.Name, outputName)).Single();

// Get input variable. The model has only one single input.
// The same way described above for output variable can be used here to get input variable by name.
Console.WriteLine(modelFunc.Arguments.Count);
for (int i = 0; i < modelFunc.Arguments.Count; i++)
{
    Console.WriteLine(modelFunc.Arguments[i].GetName());
}
Variable inputVar = modelFunc.Arguments.Where(Variable => string.Equals(Variable.Name, inputName)).Single();
var outputDataMap = new Dictionary<Variable, Value>();
Value inputVal, outputVal;
List<List<float>> outputBuffer;

// Get shape data for the input variable
NDShape inputShape = inputVar.Shape;

// Create Value for the batch data.
inputVal = Value.CreateBatch(inputVar.Shape, samples, device);

// Create input data map.
inputDataMap.Add(inputVar, inputVal);

// Create ouput data map. Using null as Value to indicate using system allocated memory.
// Alternatively, create a Value object and add it to the data map.
outputDataMap.Add(outputVar, null);

// Evaluate the model against the batch input
modelFunc.Evaluate(inputDataMap, outputDataMap, device);

// Retrieve the evaluation result.
outputBuffer = new List<List<float>>();
outputVal = outputDataMap[outputVar];
outputVal.CopyVariableValueTo(outputVar, outputBuffer);

// Output result
PrintOutput(outputVar.Shape.TotalSize, outputBuffer);  

【问题讨论】:

  • 你能发布异常吗?
  • 感谢您报告问题。我们正在调查它。例外是:System.AccessViolationException。试图读取或写入受保护的内存。

标签: c# cntk


【解决方案1】:

该异常是由错误引起的,现已修复。我们刚刚发布了 CNTK Nuget 包 2.0-Beta9.0。可以试试吗?

很抱歉给您带来不便。

谢谢,

【讨论】:

    猜你喜欢
    • 2012-09-21
    • 1970-01-01
    • 1970-01-01
    • 2011-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-08
    相关资源
    最近更新 更多