I am trying to use an "activations" function on a pretrained googlenet network. It runs ok, but returns a 4-D matrix. So I tried using ('OutputAs', 'columns') Name-Value pair. But this produces an error. Here are the reproduction steps and the error message: net = googlenet; mockImage = randn(224, 224, 3); layer = 'loss3-classifier'; trainingFeatures = activations(net, mockImage, layer, 'OutputAs', 'columns'); Error using DAGNetwork>iParseAndValidateActivationsNameValuePairs (line 598) 'OutputAs' is not a recognized parameter. For a list of valid name-value pair arguments, see the documentation for this function. Error in DAGNetwork/activations (line 230) [miniBatchSize, executionEnvironment] = iParseAndValidateActivationsNameValuePairs(varargin{:}); Error in reproduce_OutputAs_error (line 4) trainingFeatures = activations(net, mockImage, layer, 'OutputAs', 'columns'); How can I get the activations in a correct format from googlenet? The reason I am trying to do this, is to follow feature extraction example, https://www.mathworks.com/help/nnet/examples/feature-extraction-using-alexnet.html, using googlenet instead of alexnet.
Kshitij Singh answered .
2025-11-20
>> nfeatures = size(trainingFeatures, 1) * size(trainingFeatures, 2) * size(trainingFeatures, 3); >> nobservations = size(trainingFeatures, 4); >> trainingFeatures = reshape(trainingFeatures, nfeatures, nobservations); >> trainingFeatures = trainingFeatures';