# Convert the saved checkpoint of cuda-convenet to the proto of Caffe

*Credits of the scripts go to jamt9000 on github, thanks for the helpful work!

You are a deep learning consumer, you have a saved check point you trained with the cuda-convenet. You want to use Caffe to evaluate the trained neural networks on new data possiblely due to the absent of GPU. Hence you need to convert the saved checkpoint to the format compatible to Caffe.

1. check out this version of caffe: jamt9000/caffe:convert-cuda-convnet or my copy.
$git clone https://github.com/jamt9000/caffe/tree/convert-cuda-convnet convert-cuda-convnet  1. compile it following the Caffe installation instruction ## Misc. Setup$make all
$make pycaffe  1. convert the check-point with the following codesnippet import sys sys.path.append('./python/') sys.path.append('./tools/extra/') from convert_net import * if (len(sys.argv) < 2): print "Usage:- path-to-saved-convnet" sys.exit(-1) arg_convnet = sys.argv[1] output_prototxt = arg_convnet + "-prototxt" output_proto = arg_convnet + "-proto" netpt = cudaconv_to_prototxt(arg_convnet) fh=open(output_prototxt, 'w') fh.write(netpt) fh.close() print "Wrote {0}".format(output_prototxt) netpb = cudaconv_to_proto(arg_convnet) fh=open(output_proto, 'wb') fh.write(netpb.SerializeToString()) fh.close() print "Wrote {0}".format(output_proto)  $python convert-convnet2caffe.py saved-convnet-checkpoint

1. Now you should find two files: saved-convnet-checkpoint-proto and saved-convnet-checkpoint-prototxt, they are in an older format, you need some tools provided by Caffe to upgrade them.

2. checkout and compile the up-to-date (or any more recent stable) version of Caffe

3. Under build/tools/ you will find tools named upgrade_net_proto_text.bin and upgrade_net_proto_binary.bin, use them to upgrade the saved-convnet-checkpoint-proto and saved-convnet-checkpoint-prototxt accordingly.

4. Almost done, you may need to manually fix the prototext file a little bit for example, add the input layer following any example proto text files provided by the Caffe.

Good luck!