Extract Caffe features with variable batch size in Matlab

459 views Asked by At

I know how to extract Caffe feats / scores using the matcaffe_demo.m that is provided along with Caffe. However when using this file one has to provide a prototxt file that determines not only the network architecture but also the input dimensions including the batch_size.

Since I'm processing the frames of videos of variable sequence lenght I need a way to use matcaffe_demo.m along with a variable batch size.

Does anyone know how to do that?

It would probably involve changing this line from matcaffe_demo.m

% Initialize a network
net = caffe.Net(net_model, net_weights, phase);

to something that dynamically passes the current batch size needed dynamically to caffe

1

There are 1 answers

0
mcExchange On BEST ANSWER

I ended up using the reshape function:

net = caffe.Net(net_model, net_weights, phase);
net.blobs('data').reshape([dim1 dim2 numChannels numFrames]);
scores = net.forward(inputData);
caffe.reset_all();