caffe icon indicating copy to clipboard operation
caffe copied to clipboard

How to Generate Solverstate From Model / How to Initialize from Pretrained Model

Open dennis-chen opened this issue 12 years ago • 6 comments

I have a pretrained model and want to generate a solverstate so that I can use that model as initialization for my own training. Its kind of a catch-22 situation because generating solverstates requires training starting with a solverstate.

It looks like the dump_network utility might be the way to generate what I want.Running it with the arguments: dump_network.bin train.prototxt model_pretrained train_leveldb dump_out 1 produces the error:

F0703 ... 21818 data_layer.cpp:254] Check failed: prefetch_rng
*** Check failure stack trace: ***
Aborted (core dumped)

All the arguments are exactly what they sound like. Is the check failing because I misunderstand what input dump_network requires, or is it a bug in the code? Also, is there an easy way to simply generate a solverstate from a model?

dennis-chen avatar Jul 03 '14 18:07 dennis-chen

Why not finetune? https://github.com/BVLC/caffe/blob/master/tools/finetune_net.cpp

It takes a solver configuration prototxt and model weights to initialize the training.

shelhamer avatar Jul 03 '14 18:07 shelhamer

Worked great! Thanks for your help! :)

dennis-chen avatar Jul 05 '14 02:07 dennis-chen

Hi @dennis-chen, I'm using finetune_net.bin and I got a similar error. a) Are you using "Data" layer? Could you share your protofiles in pastebin? b) Did you use master or dev branch? When do you download caffe?

escorciav avatar Aug 04 '14 16:08 escorciav

To address @escorciav, I'm not sure what you mean by 'using a layer' when running finetune_net; it simply takes a solver prototxt and a pretrained model. By solver prototxt, I mean something like this. Using those two arguments in that order (using the version of caffe with the git commit-id 16fb55edc27ddbc800b6d0278b95ca8ff0b2d913) successfully generated a solverstate from the model.

seewalker avatar Aug 05 '14 22:08 seewalker

Thank you for your reply @seewalker. When I mentioned "Data" layer, I refer to the type of layer that catch your data. For the network that you mention, it is in fact a data layer because this line instantiate the type that will capture the leveldb/lmdb database. Let me know, if I explain it better this time.

escorciav avatar Aug 06 '14 19:08 escorciav

Alright, I know what you mean now. When using caffe, I've noticed the Check failed: prefetch_rng error message resulting from miscellaneous things I've done wrong. There are many many things that could be wrong. Since you mention this problem coinciding with using a data layer, one data-layer-specific problem that I've noticed produce that error is trying to use too large a batch size with the GPU (I dunno exactly what the hardware limitation is there). Try reducing your batch_size in the data layer or try running in CPU mode.

seewalker avatar Aug 07 '14 01:08 seewalker