Test a network without setting number of iterations

46 views
Skip to first unread message

Rafael Padilha

unread,
Sep 21, 2016, 6:09:20 PM9/21/16
to Caffe Users
Hi all!

I have a pre-trained network with which I would like to test my data. I defined the network architecture using a .prototxt and my data layer is a custom Python Layer that receives a .txt file with the path of my data, preprocess it and then feed to the network.

I would like to run the network until all examples have passed through the net.

However, while searching for the command to test a network, I've found (here) :

caffe test -model architecture.prototxt -weights model.caffemodel -gpu 0 -iterations 100

If I don't set the -iterations, it uses the default (50).

Does any of you know a way to run caffe test without setting the number of iterations?

Thank you very much for your help!

Przemek D

unread,
Sep 22, 2016, 5:01:32 AM9/22/16
to Caffe Users
So your network does not receive data directly, example after example, but you feed the list of examples itself into the python layer, which is supposed to load and preprocess them and control the whole inference? If I understand correctly, this would mean your python layer took control over batching and flow of images through your network, and caffe is no longer responsible for that.
Could you give us some more information on your custom data layer? What exactly does it input and briefly what does it do?

Barry

unread,
Sep 23, 2016, 11:18:44 AM9/23/16
to Caffe Users
Can't you just set iterations to 1?

Rafael Padilha

unread,
Sep 23, 2016, 1:06:58 PM9/23/16
to Barry, Caffe Users
Hey, guys! Thank you for your answers!

@Przemek
That's right! My python layer receives a .txt with two image paths and a label per line. It loads and preprocesses both images and join them into one by performing some operations. This is repeated until I have a number of images equal to the size of my batch.

The batch is forwarded through the network and, at the end of it, a Softmax layer give me the probability of a pair being of one of two classes.

The thing is... outside of my custom layer, there isn't a way of knowing when to stop (when all the pairs are processed). Or is there? 

What I'm doing is finding out how many iterations I need to run in order to process all my data (an epoch) and inserting it in the caffe test command.   


@Barry
If I set the number of iterations to 1, it will only process one batch. Since I have limited memory, I can't load all my data in a single batch.


[]s,
Rafael S. Padilha

--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/C-L-13gT_PM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/eac39bc9-de70-4415-bdf0-dd10f39d9411%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Przemek D

unread,
Sep 26, 2016, 8:55:06 AM9/26/16
to Caffe Users, barr...@gmail.com
Hmmm, this sounds like you're trying to use caffe in a way it wasn't designed to. To recap:
  • you use caffe test
  • your data is in form of pairs of images that are bound with labels in a txt file
  • you put your txt file directly into the network
  • python layer loads and preprocesses the data, packs it into a batch and calls net.forward()
I think you're "mixing authorities" here: when you run caffe test, it wants to call net.forward(), but that evaluates your python layer which also wants to call net.forward(). Now, there is no good documentation to caffe (plus I'm no expert) so I can't tell you whether this can work or not (I definitely haven't ever seen such a construct) but from my experience I can tell you, that this can be done in a cleaner way. That would be:
  • use python interface to perform inference
  • take your python layer outside of the network
  • structure your network as if all the preprocessing was already done
By "use python interface" I mean, write a python script that will:
  • iterate over your test set file
  • load and preprocess examples
  • put your data into a standard caffe input layer
  • call net.forward()
  • finish when it runs out of examples.

[]s,
Rafael S. Padilha

To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.

To post to this group, send email to caffe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages