activation() error for video classification.

Check for incorrect argument data type or missing argument in call to function 'activations'.
Error in LSTMClass (line 38)
sequences{i,1} = activations(netCNN,'somfile.avi',layerName,'OutputAs','rows');

답변 (1개)

Harshavardhan
Harshavardhan 2025년 5월 29일

0 개 추천

The error occurs because the “activations” function expects image data, such as 4-D arrays or an image datastore. To fix the error, the video frames need to be read and pre-processed first.
% Read video frames
v = VideoReader(somefile.avi);
frames = {};
while hasFrame(v)
img = readFrame(v);
frames{end+1} = img;
end
% Convert frames to 4D array
inputImages = cat(4, frames{:}); % [height, width, channels, numFrames]
% Extract features for all frames
features = activations(netCNN, inputImages, layerName, 'OutputAs', 'rows');
For more information on “VideoReader” , “readFrame”, “cat” and “activations”, refer to their respective links below.
Hope this helps.

카테고리

도움말 센터File Exchange에서 Install Products에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 3월 21일

답변:

2025년 5월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by