0

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

mcExchange
  • 6,154
  • 12
  • 57
  • 103
  • I don't know about the matcaffe I terface, but the Python interface has a function that allows you to change the input size of the net. Moreover you can give to the forward function chunks larger than the batch size, and the forward function takes care of processing the input in batches appropriately – Shai Feb 20 '16 at 20:45
  • 1
    Indeed it does. There is a reshape to modify the input dimension of the data blob. I added that as an answer below. – mcExchange Feb 22 '16 at 08:22

1 Answers1

1

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();
mcExchange
  • 6,154
  • 12
  • 57
  • 103