microsoft / CNTK

Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit
https://docs.microsoft.com/cognitive-toolkit/
Other
17.52k stars 4.28k forks source link

c++ NDArrayView and vector #2543

Open sinisha opened 7 years ago

sinisha commented 7 years ago

I have a trained model which I read using c++ API. I want to extract weights of first hidden layer to vector. Here is the code `std::vector params = model->Parameters(); CNTK::NDArrayViewPtr weightArray = params[inputLayerInd].Value();

CNTK::NDShape weightShape = params[inputLayerInd].Shape(); std::vector outputData(weightShape.TotalSize());

CNTK::NDArrayViewPtr outputArray = CNTK::MakeSharedObject(weightShape, outputData, false);

outputArray->CopyFrom(*(weightArray.get()));`

weightShape[0]=m, m is number of neurons in my hidden layer weightShape[0]=n, n is the number of input features

And this is expected since W[mxn]*x[nx1] should gave the outputs of first hidden layer.

But, I am not sure, how the data from matrix of weights are stored in outputData vector - row by row or column by column

cha-zhang commented 7 years ago

CNTK uses column major for matrices.