How to get the output of last layer after every batch as ndarray?



I’m using the Mxnet implementation of Resnet by and
I’m using the resnet for a 10 way image classification.
I use a batch size of 500 and I want to perform a matrix operation on the output obtained after the last gully connected layer. I want to access the output as NDArray(batch X no of classes i.e. 500 x 10). Till now I’m getting it as mxnet symbol and am not able to extract the data referenced with the symbol. How do I achieve this?



If you want to perform a matrix operation on the output of after the last layer, you can write the matrix operation using the symbol api and perform your matrix multiplication symbolically.

If you do want to access the values of the output though, the following lines from the code you’re using has the values: and

Alternatively, you can get the values from output symbol using

args_params, aux_params = mod.get_params()
output_ndarray = args_params['output_label']