问题描述
我知道CNTK for C#是一种新事物,但我希望有人能帮助我.我在python中跟踪了这个逻辑回归示例: https://github.com/Microsoft/CNTK/blob/master/教程/CNTK_101_LogisticRegression.ipynb 运行此C#示例: https://github.com/Microsoft/CNTK/blob/master/Examples/TrainingCSharp/Common/LogisticRegression.cs
I know CNTK for C# is kind of new but I hope someone can help me out. I was folling this logistic regression example in python:https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_101_LogisticRegression.ipynbto run this C# example:https://github.com/Microsoft/CNTK/blob/master/Examples/TrainingCSharp/Common/LogisticRegression.cs
我更改了几行以显示结果,并且代码运行无误,但我想获取权重矩阵和偏差矢量的值,因此可以在图表中画出2类之间的一条线.有人知道哪个变量包含这些值以及如何输出它们吗?教练变量? classifierOutput函数?
I changed a few lines to display the result and the code runs without errors but I would like to get the values of the weight matrix and bias vector so I can draw in my chart a line between 2 classes. Does someone know which variable contains these values and how to output them? trainer variable? classifierOutput function?
推荐答案
创建线性模型时,具有weightParam
和biasParam
参数.您可以通过以下方法从这些参数获取数据:
When you create the linear model, you have the weightParam
and biasParam
parameters. Here is how you can get data from these parameters:
NDArrayView weightArrayView = weightParam.Value();
Value weightValue = new Value(weightArrayView);
IList<IList<float>> weightData = weightValue.GetDenseData<float>(weightParam);
这篇关于CNTK C#Logistic回归w和b变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!