Open sinisha opened 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
outputData
CNTK uses column major for matrices.
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