CNTK c# logistic regression w and b variable values
Asked Answered
S

1

3

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.ipynb to run this C# example: https://github.com/Microsoft/CNTK/blob/master/Examples/TrainingCSharp/Common/LogisticRegression.cs

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?

Seto answered 11/10, 2017 at 7:56 Comment(0)
S
5

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);
Sundew answered 13/10, 2017 at 16:52 Comment(1)
This gets the data in a single flat list. Is it possible to get the data in a matrix whose shape corresponds to the actual shape of the parameter?Neediness

© 2022 - 2024 — McMap. All rights reserved.