├── .Doxyfile ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── INSTALL.md ├── LICENSE ├── Makefile ├── Makefile.config ├── Makefile.config.example ├── Makefile.mkldnn ├── README.md ├── caffe.cloc ├── cmake ├── ConfigGen.cmake ├── Cuda.cmake ├── Dependencies.cmake ├── External │ ├── gflags.cmake │ └── glog.cmake ├── MKLDNN.cmake ├── Misc.cmake ├── Modules │ ├── FindAtlas.cmake │ ├── FindGFlags.cmake │ ├── FindGlog.cmake │ ├── FindLAPACK.cmake │ ├── FindLMDB.cmake │ ├── FindLevelDB.cmake │ ├── FindMatlabMex.cmake │ ├── FindNumPy.cmake │ ├── FindOpenBLAS.cmake │ ├── FindSnappy.cmake │ └── FindvecLib.cmake ├── ProtoBuf.cmake ├── Summary.cmake ├── Targets.cmake ├── Templates │ ├── CaffeConfig.cmake.in │ ├── CaffeConfigVersion.cmake.in │ └── caffe_config.h.in ├── Utils.cmake └── lint.cmake ├── data ├── VOC0712 │ ├── coco_voc_map.txt │ ├── create_data.sh │ ├── create_list.sh │ └── labelmap_voc.prototxt ├── cifar10 │ └── get_cifar10.sh ├── coco │ ├── README.md │ ├── create_data.sh │ ├── create_list.py │ ├── diff.patch │ ├── labelmap_coco.prototxt │ └── labels.txt ├── ilsvrc12 │ └── get_ilsvrc_aux.sh └── mnist │ └── get_mnist.sh ├── docker ├── Makefile ├── README.md ├── standalone │ ├── cpu-centos │ │ └── Dockerfile │ ├── cpu-ubuntu │ │ └── Dockerfile │ └── gpu │ │ └── Dockerfile └── templates │ └── Dockerfile.template ├── docs ├── CMakeLists.txt ├── CNAME ├── README.md ├── _config.yml ├── _layouts │ └── default.html ├── development.md ├── images │ ├── GitHub-Mark-64px.png │ └── caffeine-icon.png ├── index.md ├── install_apt.md ├── install_osx.md ├── install_yum.md ├── installation_old.md ├── model_zoo.md ├── multigpu.md ├── release_notes.md ├── stylesheets │ ├── pygment_trac.css │ ├── reset.css │ └── styles.css └── tutorial │ ├── convolution.md │ ├── data.md │ ├── fig │ ├── .gitignore │ ├── backward.jpg │ ├── forward.jpg │ ├── forward_backward.png │ ├── layer.jpg │ └── logreg.jpg │ ├── forward_backward.md │ ├── index.md │ ├── interfaces.md │ ├── layers.md │ ├── loss.md │ ├── net_layer_blob.md │ └── solver.md ├── examples ├── 00-classification.ipynb ├── 01-learning-lenet.ipynb ├── 02-fine-tuning.ipynb ├── C3D_train │ ├── 1.avi │ ├── c3d.prototxt │ ├── c3d_solver.prototxt │ ├── run_C3d.sh │ └── whole_frame.py ├── CMakeLists.txt ├── LRCN_activity_recognition │ ├── README.txt │ ├── classify_video.py │ ├── deploy_lstm.prototxt │ ├── extract_frames.sh │ ├── lstm_solver_RGB.prototxt │ ├── run_lstm_RGB.sh │ ├── run_singleFrame_RGB.sh │ ├── sequence_input_layer.py │ ├── singleFrame_solver_RGB.prototxt │ ├── train_test_lstm_RGB.prototxt │ ├── train_test_singleFrame_RGB.prototxt │ ├── ucf101_split1_testVideos.txt │ ├── ucf101_split1_trainVideos.txt │ └── verify_videos.sh ├── brewing-logreg.ipynb ├── cifar10 │ ├── cifar10_full.prototxt │ ├── cifar10_full_sigmoid_solver.prototxt │ ├── cifar10_full_sigmoid_solver_bn.prototxt │ ├── cifar10_full_sigmoid_train_test.prototxt │ ├── cifar10_full_sigmoid_train_test_bn.prototxt │ ├── cifar10_full_solver.prototxt │ ├── cifar10_full_solver_lr1.prototxt │ ├── cifar10_full_solver_lr2.prototxt │ ├── cifar10_full_train_test.prototxt │ ├── cifar10_quick.prototxt │ ├── cifar10_quick_solver.prototxt │ ├── cifar10_quick_solver_lr1.prototxt │ ├── cifar10_quick_train_test.prototxt │ ├── convert_cifar_data.cpp │ ├── create_cifar10.sh │ ├── readme.md │ ├── train_full.sh │ ├── train_full_multinode_mpi.sh │ ├── train_full_sigmoid.sh │ ├── train_full_sigmoid_bn.sh │ └── train_quick.sh ├── cpp_classification │ ├── batch_classification.cpp │ ├── classification.cpp │ └── readme.md ├── detection.ipynb ├── feature_extraction │ ├── imagenet_val.prototxt │ └── readme.md ├── finetune_flickr_style │ ├── assemble_data.py │ ├── flickr_style.csv.gz │ ├── readme.md │ └── style_names.txt ├── finetune_pascal_detection │ ├── pascal_finetune_solver.prototxt │ └── pascal_finetune_trainval_test.prototxt ├── hdf5_classification │ ├── nonlinear_auto_test.prototxt │ ├── nonlinear_auto_train.prototxt │ ├── nonlinear_train_val.prototxt │ └── train_val.prototxt ├── imagenet │ ├── create_imagenet.sh │ ├── make_imagenet_mean.sh │ ├── readme.md │ ├── resume_training.sh │ └── train_caffenet.sh ├── images │ ├── cat gray.jpg │ ├── cat.jpg │ ├── cat_gray.jpg │ └── fish-bike.jpg ├── mnist │ ├── convert_mnist_data.cpp │ ├── create_mnist.sh │ ├── lenet.prototxt │ ├── lenet_adadelta_solver.prototxt │ ├── lenet_auto_solver.prototxt │ ├── lenet_consolidated_solver.prototxt │ ├── lenet_multistep_solver.prototxt │ ├── lenet_solver.prototxt │ ├── lenet_solver_adam.prototxt │ ├── lenet_solver_mlsl.prototxt │ ├── lenet_solver_mlsl2.prototxt │ ├── lenet_solver_mlsl3.prototxt │ ├── lenet_solver_rmsprop.prototxt │ ├── lenet_train_test.prototxt │ ├── lenet_train_test_mlsl.prototxt │ ├── lenet_train_test_mlsl2.prototxt │ ├── lenet_train_test_mlsl3.prototxt │ ├── mnist_autoencoder.prototxt │ ├── mnist_autoencoder_solver.prototxt │ ├── mnist_autoencoder_solver_adadelta.prototxt │ ├── mnist_autoencoder_solver_adagrad.prototxt │ ├── mnist_autoencoder_solver_nesterov.prototxt │ ├── readme.md │ ├── train_lenet.sh │ ├── train_lenet_adam.sh │ ├── train_lenet_consolidated.sh │ ├── train_lenet_docker.sh │ ├── train_lenet_rmsprop.sh │ ├── train_mnist_autoencoder.sh │ ├── train_mnist_autoencoder_adadelta.sh │ ├── train_mnist_autoencoder_adagrad.sh │ └── train_mnist_autoencoder_nesterov.sh ├── net_surgery.ipynb ├── net_surgery │ ├── bvlc_caffenet_full_conv.prototxt │ └── conv.prototxt ├── pascal-multilabel-with-datalayer.ipynb ├── pycaffe │ ├── caffenet.py │ ├── layers │ │ ├── pascal_multilabel_datalayers.py │ │ └── pyloss.py │ ├── linreg.prototxt │ ├── tools.py │ ├── tune_engine.py │ ├── tune_model.py │ └── utils.py ├── siamese │ ├── convert_mnist_siamese_data.cpp │ ├── create_mnist_siamese.sh │ ├── mnist_siamese.ipynb │ ├── mnist_siamese.prototxt │ ├── mnist_siamese_solver.prototxt │ ├── mnist_siamese_train_test.prototxt │ ├── readme.md │ └── train_mnist_siamese.sh ├── ssd │ ├── images.txt │ ├── ssd_detect.cpp │ └── ssdvars.sh ├── test_blobs │ ├── ImageDataLayerTest_TestRead_d.blob │ ├── ImageDataLayerTest_TestRead_f.blob │ ├── ImageDataLayerTest_TestResize_d.blob │ ├── ImageDataLayerTest_TestResize_f.blob │ ├── ImageDataLayerTest_TestShuffle_d.blob │ └── ImageDataLayerTest_TestShuffle_f.blob ├── video.list └── web_demo │ ├── app.py │ ├── exifutil.py │ ├── readme.md │ ├── requirements.txt │ └── templates │ └── index.html ├── external ├── mkl │ └── prepare_mkl.sh └── mlsl │ └── prepare_mlsl.sh ├── include ├── caffe │ ├── blob.hpp │ ├── caffe.hpp │ ├── common.hpp │ ├── data_reader.hpp │ ├── data_transformer.hpp │ ├── engine_parser.hpp │ ├── filler.hpp │ ├── gabor.hpp │ ├── internal_thread.hpp │ ├── layer.hpp │ ├── layer_factory.hpp │ ├── layers │ │ ├── absval_layer.hpp │ │ ├── accuracy_layer.hpp │ │ ├── annotated_data_layer.hpp │ │ ├── argmax_layer.hpp │ │ ├── base_conv_layer.hpp │ │ ├── base_data_layer.hpp │ │ ├── batch_norm_layer.hpp │ │ ├── batch_reindex_layer.hpp │ │ ├── bias_layer.hpp │ │ ├── bnll_layer.hpp │ │ ├── concat_layer.hpp │ │ ├── contrastive_loss_layer.hpp │ │ ├── conv_layer.hpp │ │ ├── crop_layer.hpp │ │ ├── cudnn_conv_layer.hpp │ │ ├── cudnn_lcn_layer.hpp │ │ ├── cudnn_lrn_layer.hpp │ │ ├── cudnn_pooling_layer.hpp │ │ ├── cudnn_relu_layer.hpp │ │ ├── cudnn_sigmoid_layer.hpp │ │ ├── cudnn_softmax_layer.hpp │ │ ├── cudnn_tanh_layer.hpp │ │ ├── data_layer.hpp │ │ ├── deconv_layer.hpp │ │ ├── detection_evaluate_layer.hpp │ │ ├── detection_output_layer.hpp │ │ ├── dropout_layer.hpp │ │ ├── dummy_data_layer.hpp │ │ ├── eltwise_layer.hpp │ │ ├── elu_layer.hpp │ │ ├── embed_layer.hpp │ │ ├── euclidean_loss_layer.hpp │ │ ├── exp_layer.hpp │ │ ├── filter_layer.hpp │ │ ├── flatten_layer.hpp │ │ ├── hdf5_data_layer.hpp │ │ ├── hdf5_output_layer.hpp │ │ ├── hinge_loss_layer.hpp │ │ ├── im2col_layer.hpp │ │ ├── image_data_layer.hpp │ │ ├── infogain_loss_layer.hpp │ │ ├── inner_product_layer.hpp │ │ ├── input_layer.hpp │ │ ├── log_layer.hpp │ │ ├── loss_layer.hpp │ │ ├── lrn_layer.hpp │ │ ├── lstm_layer.hpp │ │ ├── memory_data_layer.hpp │ │ ├── mkl_layers.hpp │ │ ├── mkldnn_layers.hpp │ │ ├── multibox_loss_layer.hpp │ │ ├── multinomial_logistic_loss_layer.hpp │ │ ├── mvn_layer.hpp │ │ ├── neuron_layer.hpp │ │ ├── normalize_layer.hpp │ │ ├── parameter_layer.hpp │ │ ├── permute_layer.hpp │ │ ├── pooling_layer.hpp │ │ ├── pooling_layer_impl.hpp │ │ ├── power_layer.hpp │ │ ├── prelu_layer.hpp │ │ ├── prior_box_layer.hpp │ │ ├── python_layer.hpp │ │ ├── recurrent_layer.hpp │ │ ├── reduction_layer.hpp │ │ ├── relu_layer.hpp │ │ ├── reshape_layer.hpp │ │ ├── rnn_layer.hpp │ │ ├── scale_layer.hpp │ │ ├── sigmoid_cross_entropy_loss_layer.hpp │ │ ├── sigmoid_layer.hpp │ │ ├── silence_layer.hpp │ │ ├── slice_layer.hpp │ │ ├── smooth_L1_loss_layer.hpp │ │ ├── softmax_layer.hpp │ │ ├── softmax_loss_layer.hpp │ │ ├── split_layer.hpp │ │ ├── spp_layer.hpp │ │ ├── tanh_layer.hpp │ │ ├── threshold_layer.hpp │ │ ├── tile_layer.hpp │ │ ├── video_data_layer.hpp │ │ └── window_data_layer.hpp │ ├── mkl_memory.hpp │ ├── mkldnn_base.hpp │ ├── mkldnn_memory.hpp │ ├── multinode │ │ ├── apply_mn_param.hpp │ │ ├── mlsl.hpp │ │ ├── mn_activation_layer.hpp │ │ ├── multi_solver.hpp │ │ └── multi_sync.hpp │ ├── net.hpp │ ├── parallel.hpp │ ├── serialization │ │ └── ProtoSerialize.hpp │ ├── sgd_solvers.hpp │ ├── solver.hpp │ ├── solver_factory.hpp │ ├── syncedmem.hpp │ ├── test │ │ ├── test_caffe_main.hpp │ │ └── test_gradient_check_util.hpp │ ├── training_utils.hpp │ └── util │ │ ├── bbox_util.hpp │ │ ├── benchmark.hpp │ │ ├── blocking_queue.hpp │ │ ├── compareToolUtilities.h │ │ ├── cpu_info.hpp │ │ ├── cudnn.hpp │ │ ├── db.hpp │ │ ├── db_leveldb.hpp │ │ ├── db_lmdb.hpp │ │ ├── device_alternate.hpp │ │ ├── float_compare.hpp │ │ ├── format.hpp │ │ ├── gpu_util.cuh │ │ ├── hdf5.hpp │ │ ├── im2col.hpp │ │ ├── im_transforms.hpp │ │ ├── insert_splits.hpp │ │ ├── io.hpp │ │ ├── math_functions.hpp │ │ ├── mkl_alternate.hpp │ │ ├── performance.hpp │ │ ├── remove_batch_norm.hpp │ │ ├── rng.hpp │ │ ├── sampler.hpp │ │ ├── signal_handler.h │ │ └── upgrade_proto.hpp └── mkl_dnn_cppwrapper.h ├── matlab ├── +caffe │ ├── +test │ │ ├── test_io.m │ │ ├── test_net.m │ │ └── test_solver.m │ ├── Blob.m │ ├── Layer.m │ ├── Net.m │ ├── Solver.m │ ├── get_net.m │ ├── get_solver.m │ ├── imagenet │ │ └── ilsvrc_2012_mean.mat │ ├── io.m │ ├── private │ │ ├── CHECK.m │ │ ├── CHECK_FILE_EXIST.m │ │ ├── caffe_.cpp │ │ └── is_valid_handle.m │ ├── reset_all.m │ ├── run_tests.m │ ├── set_device.m │ ├── set_mode_cpu.m │ ├── set_mode_gpu.m │ └── version.m ├── CMakeLists.txt ├── demo │ └── classification_demo.m └── hdf5creation │ ├── .gitignore │ ├── demo.m │ └── store2hdf5.m ├── mkldnn.commit ├── models ├── bvlc_alexnet │ ├── deploy.prototxt │ ├── readme.md │ ├── solver.prototxt │ ├── solver_client.prototxt │ ├── solver_param_server.prototxt │ ├── train_val.prototxt │ ├── train_val_client.prototxt │ └── train_val_param_server.prototxt ├── bvlc_googlenet │ ├── deploy.prototxt │ ├── quick_solver.prototxt │ ├── readme.md │ ├── solver.prototxt │ ├── solver_client.prototxt │ ├── solver_param_server.prototxt │ ├── train_val.prototxt │ ├── train_val_client.prototxt │ └── train_val_param_server.prototxt ├── bvlc_reference_caffenet │ ├── deploy.prototxt │ ├── readme.md │ ├── solver.prototxt │ └── train_val.prototxt ├── bvlc_reference_rcnn_ilsvrc13 │ ├── deploy.prototxt │ └── readme.md ├── default_googlenet_v2 │ ├── solver.prototxt │ └── train_val.prototxt ├── default_resnet_50 │ ├── LICENSE │ ├── solver.prototxt │ └── train_val.prototxt ├── default_vgg_16 │ ├── solver.prototxt │ └── train_val.prototxt ├── default_vgg_19 │ ├── solver.prototxt │ └── train_val.prototxt ├── finetune_flickr_style │ ├── deploy.prototxt │ ├── readme.md │ ├── solver.prototxt │ └── train_val.prototxt └── intel_optimized_models │ ├── alexnet │ ├── solver.prototxt │ ├── solver_gabor_init.prototxt │ ├── train_val.prototxt │ └── train_val_gabor_init.prototxt │ ├── googlenet │ ├── solver.prototxt │ └── train_val.prototxt │ ├── googlenet_v2 │ ├── solver.prototxt │ └── train_val.prototxt │ ├── multinode │ ├── alexnet_4nodes │ │ ├── solver.prototxt │ │ └── train_val.prototxt │ ├── googlenet_4nodes │ │ ├── solver.prototxt │ │ └── train_val.prototxt │ ├── googlenet_8nodes │ │ ├── solver.prototxt │ │ └── train_val.prototxt │ ├── googlenet_v2_8nodes │ │ ├── solver.prototxt │ │ └── train_val.prototxt │ ├── resnet_50_256_nodes_8k_batch │ │ ├── solver.prototxt │ │ └── train_val.prototxt │ └── vgg_16_8nodes │ │ ├── solver.prototxt │ │ └── train_val.prototxt │ ├── resnet_50 │ ├── solver.prototxt │ └── train_val.prototxt │ └── ssd │ ├── AlexNet │ └── VOC0712 │ │ └── SSD_300x300 │ │ ├── deploy.prototxt │ │ ├── solver.prototxt │ │ ├── test.prototxt │ │ └── train.prototxt │ └── VGGNet │ ├── VOC0712 │ ├── SSD_300x300 │ │ ├── deploy.prototxt │ │ ├── deploy_mkl2017.prototxt │ │ ├── deploy_mkldnn.prototxt │ │ ├── solver.prototxt │ │ ├── test.prototxt │ │ └── train.prototxt │ └── SSD_300x300_webcam │ │ └── test.prototxt │ └── coco │ ├── SSD_300x300 │ ├── deploy.prototxt │ ├── solver.prototxt │ ├── test.prototxt │ └── train.prototxt │ └── SSD_300x300_webcam │ └── test.prototxt ├── python ├── CMakeLists.txt ├── caffe │ ├── __init__.py │ ├── _caffe.cpp │ ├── classifier.py │ ├── coord_map.py │ ├── detector.py │ ├── draw.py │ ├── imagenet │ │ └── ilsvrc_2012_mean.npy │ ├── io.py │ ├── model_libs.py │ ├── net_spec.py │ ├── pycaffe.py │ └── test │ │ ├── test_coord_map.py │ │ ├── test_draw.py │ │ ├── test_io.py │ │ ├── test_layer_type_list.py │ │ ├── test_net.py │ │ ├── test_net_spec.py │ │ ├── test_python_layer.py │ │ ├── test_python_layer_with_param_str.py │ │ └── test_solver.py ├── classify.py ├── detect.py ├── draw_net.py └── requirements.txt ├── scripts ├── SystemTap │ ├── CMakeLists.txt │ └── profile_selected_function.stp ├── build_docs.sh ├── convert_inception_v3.py ├── copy_notebook.py ├── cpp_lint.py ├── create_annoset.py ├── deploy_docs.sh ├── download_model_binary.py ├── download_model_from_gist.sh ├── gather_examples.sh ├── travis │ ├── build.sh │ ├── configure-cmake.sh │ ├── configure-make.sh │ ├── configure.sh │ ├── defaults.sh │ ├── install-deps.sh │ ├── install-python-deps.sh │ ├── setup-venv.sh │ └── test.sh └── upload_model_to_gist.sh ├── src ├── caffe │ ├── CMakeLists.txt │ ├── blob.cpp │ ├── common.cpp │ ├── data_reader.cpp │ ├── data_transformer.cpp │ ├── internal_thread.cpp │ ├── layer.cpp │ ├── layer_factory.cpp │ ├── layers │ │ ├── absval_layer.cpp │ │ ├── absval_layer.cu │ │ ├── accuracy_layer.cpp │ │ ├── annotated_data_layer.cpp │ │ ├── argmax_layer.cpp │ │ ├── base_conv_layer.cpp │ │ ├── base_data_layer.cpp │ │ ├── base_data_layer.cu │ │ ├── batch_norm_layer.cpp │ │ ├── batch_norm_layer.cu │ │ ├── batch_reindex_layer.cpp │ │ ├── batch_reindex_layer.cu │ │ ├── bias_layer.cpp │ │ ├── bias_layer.cu │ │ ├── bnll_layer.cpp │ │ ├── bnll_layer.cu │ │ ├── concat_layer.cpp │ │ ├── concat_layer.cu │ │ ├── contrastive_loss_layer.cpp │ │ ├── contrastive_loss_layer.cu │ │ ├── conv_layer.cpp │ │ ├── conv_layer.cu │ │ ├── crop_layer.cpp │ │ ├── crop_layer.cu │ │ ├── cudnn_conv_layer.cpp │ │ ├── cudnn_conv_layer.cu │ │ ├── cudnn_lcn_layer.cpp │ │ ├── cudnn_lcn_layer.cu │ │ ├── cudnn_lrn_layer.cpp │ │ ├── cudnn_lrn_layer.cu │ │ ├── cudnn_pooling_layer.cpp │ │ ├── cudnn_pooling_layer.cu │ │ ├── cudnn_relu_layer.cpp │ │ ├── cudnn_relu_layer.cu │ │ ├── cudnn_sigmoid_layer.cpp │ │ ├── cudnn_sigmoid_layer.cu │ │ ├── cudnn_softmax_layer.cpp │ │ ├── cudnn_softmax_layer.cu │ │ ├── cudnn_tanh_layer.cpp │ │ ├── cudnn_tanh_layer.cu │ │ ├── data_layer.cpp │ │ ├── deconv_layer.cpp │ │ ├── deconv_layer.cu │ │ ├── detection_evaluate_layer.cpp │ │ ├── detection_output_layer.cpp │ │ ├── detection_output_layer.cu │ │ ├── dropout_layer.cpp │ │ ├── dropout_layer.cu │ │ ├── dummy_data_layer.cpp │ │ ├── eltwise_layer.cpp │ │ ├── eltwise_layer.cu │ │ ├── elu_layer.cpp │ │ ├── elu_layer.cu │ │ ├── embed_layer.cpp │ │ ├── embed_layer.cu │ │ ├── euclidean_loss_layer.cpp │ │ ├── euclidean_loss_layer.cu │ │ ├── exp_layer.cpp │ │ ├── exp_layer.cu │ │ ├── filter_layer.cpp │ │ ├── filter_layer.cu │ │ ├── flatten_layer.cpp │ │ ├── hdf5_data_layer.cpp │ │ ├── hdf5_data_layer.cu │ │ ├── hdf5_output_layer.cpp │ │ ├── hdf5_output_layer.cu │ │ ├── hinge_loss_layer.cpp │ │ ├── im2col_layer.cpp │ │ ├── im2col_layer.cu │ │ ├── image_data_layer.cpp │ │ ├── infogain_loss_layer.cpp │ │ ├── inner_product_layer.cpp │ │ ├── inner_product_layer.cu │ │ ├── input_layer.cpp │ │ ├── log_layer.cpp │ │ ├── log_layer.cu │ │ ├── loss_layer.cpp │ │ ├── lrn_layer.cpp │ │ ├── lrn_layer.cu │ │ ├── lstm_layer.cpp │ │ ├── lstm_unit_layer.cpp │ │ ├── lstm_unit_layer.cu │ │ ├── memory_data_layer.cpp │ │ ├── mkl_batch_norm_layer.cpp │ │ ├── mkl_concat_layer.cpp │ │ ├── mkl_convolution_layer.cpp │ │ ├── mkl_deconvolution_layer.cpp │ │ ├── mkl_eltwise_layer.cpp │ │ ├── mkl_lrn_layer.cpp │ │ ├── mkl_pooling_layer.cpp │ │ ├── mkl_relu_layer.cpp │ │ ├── mkl_split_layer.cpp │ │ ├── mkldnn_batch_norm_layer.cpp │ │ ├── mkldnn_concat_layer.cpp │ │ ├── mkldnn_convolution_layer.cpp │ │ ├── mkldnn_eltwise_layer.cpp │ │ ├── mkldnn_inner_product_layer.cpp │ │ ├── mkldnn_lrn_layer.cpp │ │ ├── mkldnn_pooling_layer.cpp │ │ ├── mkldnn_relu_layer.cpp │ │ ├── mkldnn_split_layer.cpp │ │ ├── multibox_loss_layer.cpp │ │ ├── multinomial_logistic_loss_layer.cpp │ │ ├── mvn_layer.cpp │ │ ├── mvn_layer.cu │ │ ├── neuron_layer.cpp │ │ ├── normalize_layer.cpp │ │ ├── normalize_layer.cu │ │ ├── parameter_layer.cpp │ │ ├── permute_layer.cpp │ │ ├── permute_layer.cu │ │ ├── pooling_layer.cpp │ │ ├── pooling_layer.cu │ │ ├── pooling_layer_impl.cpp │ │ ├── power_layer.cpp │ │ ├── power_layer.cu │ │ ├── prelu_layer.cpp │ │ ├── prelu_layer.cu │ │ ├── prior_box_layer.cpp │ │ ├── recurrent_layer.cpp │ │ ├── recurrent_layer.cu │ │ ├── reduction_layer.cpp │ │ ├── reduction_layer.cu │ │ ├── relu_layer.cpp │ │ ├── relu_layer.cu │ │ ├── reshape_layer.cpp │ │ ├── rnn_layer.cpp │ │ ├── scale_layer.cpp │ │ ├── scale_layer.cu │ │ ├── sigmoid_cross_entropy_loss_layer.cpp │ │ ├── sigmoid_cross_entropy_loss_layer.cu │ │ ├── sigmoid_layer.cpp │ │ ├── sigmoid_layer.cu │ │ ├── silence_layer.cpp │ │ ├── silence_layer.cu │ │ ├── slice_layer.cpp │ │ ├── slice_layer.cu │ │ ├── smooth_L1_loss_layer.cpp │ │ ├── smooth_L1_loss_layer.cu │ │ ├── softmax_layer.cpp │ │ ├── softmax_layer.cu │ │ ├── softmax_loss_layer.cpp │ │ ├── softmax_loss_layer.cu │ │ ├── split_layer.cpp │ │ ├── split_layer.cu │ │ ├── spp_layer.cpp │ │ ├── tanh_layer.cpp │ │ ├── tanh_layer.cu │ │ ├── threshold_layer.cpp │ │ ├── threshold_layer.cu │ │ ├── tile_layer.cpp │ │ ├── tile_layer.cu │ │ ├── video_data_layer.cpp │ │ └── window_data_layer.cpp │ ├── mkl_memory.cpp │ ├── mkldnn_base.cpp │ ├── mkldnn_memory.cpp │ ├── multinode │ │ ├── apply_mn_param.cpp │ │ ├── mlsl.cpp │ │ ├── mn_activation_layer.cpp │ │ ├── multi_solver.cpp │ │ └── multi_sync.cpp │ ├── net.cpp │ ├── parallel.cpp │ ├── proto │ │ └── caffe.proto │ ├── serialization │ │ └── ProtoSerialize.cpp │ ├── solver.cpp │ ├── solvers │ │ ├── adadelta_solver.cpp │ │ ├── adadelta_solver.cu │ │ ├── adagrad_solver.cpp │ │ ├── adagrad_solver.cu │ │ ├── adam_solver.cpp │ │ ├── adam_solver.cu │ │ ├── nesterov_solver.cpp │ │ ├── nesterov_solver.cu │ │ ├── rmsprop_solver.cpp │ │ ├── rmsprop_solver.cu │ │ ├── sgd_solver.cpp │ │ └── sgd_solver.cu │ ├── syncedmem.cpp │ ├── test │ │ ├── CMakeLists.txt │ │ ├── test_accuracy_layer.cpp │ │ ├── test_annotated_data_layer.cpp │ │ ├── test_argmax_layer.cpp │ │ ├── test_batch_norm_layer.cpp │ │ ├── test_batch_reindex_layer.cpp │ │ ├── test_bbox_util.cpp │ │ ├── test_benchmark.cpp │ │ ├── test_bias_layer.cpp │ │ ├── test_blob.cpp │ │ ├── test_caffe_main.cpp │ │ ├── test_common.cpp │ │ ├── test_concat_layer.cpp │ │ ├── test_contrastive_loss_layer.cpp │ │ ├── test_convolution_layer.cpp │ │ ├── test_cpu_info.cpp │ │ ├── test_crop_layer.cpp │ │ ├── test_data │ │ │ ├── generate_sample_data.py │ │ │ ├── sample_data.h5 │ │ │ ├── sample_data_2_gzip.h5 │ │ │ ├── sample_data_list.txt │ │ │ ├── solver_data.h5 │ │ │ ├── solver_data_list.txt │ │ │ └── test_topology.prototxt │ │ ├── test_data_layer.cpp │ │ ├── test_data_transformer.cpp │ │ ├── test_db.cpp │ │ ├── test_deconvolution_layer.cpp │ │ ├── test_detection_evaluate_layer.cpp │ │ ├── test_detection_output_layer.cpp │ │ ├── test_dummy_data_layer.cpp │ │ ├── test_eltwise_layer.cpp │ │ ├── test_embed_layer.cpp │ │ ├── test_engine_selection.cpp │ │ ├── test_euclidean_loss_layer.cpp │ │ ├── test_filler.cpp │ │ ├── test_filter_layer.cpp │ │ ├── test_flatten_layer.cpp │ │ ├── test_float_compare.cpp │ │ ├── test_gradient_based_solver.cpp │ │ ├── test_hdf5_output_layer.cpp │ │ ├── test_hdf5data_layer.cpp │ │ ├── test_hinge_loss_layer.cpp │ │ ├── test_im2col_kernel.cu │ │ ├── test_im2col_layer.cpp │ │ ├── test_im_transforms.cpp │ │ ├── test_image_data_layer.cpp │ │ ├── test_infogain_loss_layer.cpp │ │ ├── test_inner_product_layer.cpp │ │ ├── test_internal_thread.cpp │ │ ├── test_io.cpp │ │ ├── test_layer_factory.cpp │ │ ├── test_lrn_layer.cpp │ │ ├── test_lstm_layer.cpp │ │ ├── test_math_functions.cpp │ │ ├── test_maxpool_dropout_layers.cpp │ │ ├── test_memory_data_layer.cpp │ │ ├── test_mkl_batch_norm_layer.cpp │ │ ├── test_mkl_concat_layer.cpp │ │ ├── test_mkl_convolution_layer.cpp │ │ ├── test_mkl_deconvolution_layer.cpp │ │ ├── test_mkl_eltwise_layer.cpp │ │ ├── test_mkl_lrn_layer.cpp │ │ ├── test_mkl_neuron_layers.cpp │ │ ├── test_mkl_pooling_layer.cpp │ │ ├── test_mkl_split_layer.cpp │ │ ├── test_mkldnn_batch_norm_layer.cpp │ │ ├── test_mkldnn_concat_layer.cpp │ │ ├── test_mkldnn_convolution_layer.cpp │ │ ├── test_mkldnn_eltwise_layer.cpp │ │ ├── test_mkldnn_inner_product_layer.cpp │ │ ├── test_mkldnn_lrn_layer.cpp │ │ ├── test_mkldnn_neuron_layers.cpp │ │ ├── test_mkldnn_pooling_layer.cpp │ │ ├── test_mkldnn_split_layer.cpp │ │ ├── test_multibox_loss_layer.cpp │ │ ├── test_multinomial_logistic_loss_layer.cpp │ │ ├── test_mvn_layer.cpp │ │ ├── test_net.cpp │ │ ├── test_neuron_layer.cpp │ │ ├── test_normalize_layer.cpp │ │ ├── test_permute_layer.cpp │ │ ├── test_platform.cpp │ │ ├── test_pooling_layer.cpp │ │ ├── test_power_layer.cpp │ │ ├── test_prior_box_layer.cpp │ │ ├── test_protobuf.cpp │ │ ├── test_random_number_generator.cpp │ │ ├── test_reduction_layer.cpp │ │ ├── test_reshape_layer.cpp │ │ ├── test_rnn_layer.cpp │ │ ├── test_scale_layer.cpp │ │ ├── test_sigmoid_cross_entropy_loss_layer.cpp │ │ ├── test_slice_layer.cpp │ │ ├── test_smooth_L1_loss_layer.cpp │ │ ├── test_softmax_layer.cpp │ │ ├── test_softmax_with_loss_layer.cpp │ │ ├── test_solver.cpp │ │ ├── test_solver_factory.cpp │ │ ├── test_split_layer.cpp │ │ ├── test_spp_layer.cpp │ │ ├── test_stochastic_pooling.cpp │ │ ├── test_syncedmem.cpp │ │ ├── test_tanh_layer.cpp │ │ ├── test_threshold_layer.cpp │ │ ├── test_tile_layer.cpp │ │ ├── test_training_utils.cpp │ │ ├── test_upgrade_proto.cpp │ │ └── test_util_blas.cpp │ └── util │ │ ├── bbox_util.cpp │ │ ├── bbox_util.cu │ │ ├── benchmark.cpp │ │ ├── blocking_queue.cpp │ │ ├── cpu_info.cpp │ │ ├── cudnn.cpp │ │ ├── db.cpp │ │ ├── db_leveldb.cpp │ │ ├── db_lmdb.cpp │ │ ├── hdf5.cpp │ │ ├── im2col.cpp │ │ ├── im2col.cu │ │ ├── im_transforms.cpp │ │ ├── insert_splits.cpp │ │ ├── io.cpp │ │ ├── math_functions.cpp │ │ ├── math_functions.cu │ │ ├── remove_batch_norm.cpp │ │ ├── sampler.cpp │ │ ├── signal_handler.cpp │ │ └── upgrade_proto.cpp ├── gmock │ ├── CHANGES │ ├── CMakeLists.txt │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── README │ ├── configure.ac │ ├── include │ │ └── gmock │ │ │ ├── gmock-actions.h │ │ │ ├── gmock-cardinalities.h │ │ │ ├── gmock-generated-actions.h │ │ │ ├── gmock-generated-actions.h.pump │ │ │ ├── gmock-generated-function-mockers.h │ │ │ ├── gmock-generated-function-mockers.h.pump │ │ │ ├── gmock-generated-matchers.h │ │ │ ├── gmock-generated-matchers.h.pump │ │ │ ├── gmock-generated-nice-strict.h │ │ │ ├── gmock-generated-nice-strict.h.pump │ │ │ ├── gmock-matchers.h │ │ │ ├── gmock-more-actions.h │ │ │ ├── gmock-more-matchers.h │ │ │ ├── gmock-spec-builders.h │ │ │ ├── gmock.h │ │ │ └── internal │ │ │ ├── gmock-generated-internal-utils.h │ │ │ ├── gmock-generated-internal-utils.h.pump │ │ │ ├── gmock-internal-utils.h │ │ │ └── gmock-port.h │ └── src │ │ ├── gmock-all.cpp │ │ ├── gmock-cardinalities.cc │ │ ├── gmock-internal-utils.cc │ │ ├── gmock-matchers.cc │ │ ├── gmock-spec-builders.cc │ │ └── gmock.cc └── gtest │ ├── CHANGES │ ├── CMakeLists.txt │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── README │ ├── cmake │ └── internal_utils.cmake │ ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-param-test.h.pump │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-linked_ptr.h │ │ ├── gtest-param-util-generated.h │ │ ├── gtest-param-util-generated.h.pump │ │ ├── gtest-param-util.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ ├── gtest-tuple.h │ │ ├── gtest-tuple.h.pump │ │ ├── gtest-type-util.h │ │ └── gtest-type-util.h.pump │ └── src │ ├── gtest-all.cpp │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ └── gtest.cc ├── tools ├── CMakeLists.txt ├── caffe.cpp ├── compute_image_mean.cpp ├── convert_annoset.cpp ├── convert_imageset.cpp ├── create_label_map.cpp ├── device_query.cpp ├── extra │ ├── extract_seconds.py │ ├── launch_resize_and_crop_images.sh │ ├── parse_log.py │ ├── parse_log.sh │ ├── plot_detections.py │ ├── plot_log.gnuplot.example │ ├── plot_training_log.py.example │ ├── resize_and_crop_images.py │ └── summarize.py ├── extract_features.cpp ├── finetune_net.cpp ├── get_image_size.cpp ├── net_speed_benchmark.cpp ├── test_net.cpp ├── train_net.cpp ├── upgrade_net_proto_binary.cpp ├── upgrade_net_proto_text.cpp └── upgrade_solver_proto_text.cpp └── xbyak ├── COPYRIGHT ├── xbyak.h ├── xbyak_bin2hex.h ├── xbyak_mnemonic.h └── xbyak_util.h /.gitignore: -------------------------------------------------------------------------------- 1 | ## General 2 | 3 | # Compiled Object files 4 | *.slo 5 | *.lo 6 | *.o 7 | *.cuo 8 | 9 | # Compiled Dynamic libraries 10 | *.so 11 | *.dylib 12 | 13 | # Compiled Static libraries 14 | *.lai 15 | *.la 16 | *.a 17 | 18 | # Compiled protocol buffers 19 | *.pb.h 20 | *.pb.cc 21 | *_pb2.py 22 | 23 | # Compiled python 24 | *.pyc 25 | 26 | # Compiled MATLAB 27 | *.mex* 28 | 29 | # IPython notebook checkpoints 30 | .ipynb_checkpoints 31 | 32 | # Editor temporaries 33 | *.swp 34 | *~ 35 | 36 | # Sublime Text settings 37 | *.sublime-workspace 38 | *.sublime-project 39 | 40 | # Eclipse Project settings 41 | *.*project 42 | .settings 43 | 44 | # QtCreator files 45 | *.user 46 | 47 | # PyCharm files 48 | .idea 49 | 50 | # OSX dir files 51 | .DS_Store 52 | 53 | ## Caffe 54 | 55 | # User's build configuration 56 | Makefile.config 57 | 58 | # Data and models are either 59 | # 1. reference, and not casually committed 60 | # 2. custom, and live on their own unless they're deliberated contributed 61 | data/* 62 | models/* 63 | *.caffemodel 64 | *.caffemodel.h5 65 | *.solverstate 66 | *.solverstate.h5 67 | *.binaryproto 68 | *leveldb 69 | *lmdb 70 | 71 | # build, distribute, and bins (+ python proto bindings) 72 | build 73 | .build_debug/* 74 | .build_release/* 75 | distribute/* 76 | *.testbin 77 | *.bin 78 | python/caffe/proto/ 79 | cmake_build 80 | .cmake_build 81 | nbproject/* 82 | 83 | # Generated documentation 84 | docs/_site 85 | docs/gathered 86 | _site 87 | doxygen 88 | docs/dev 89 | 90 | # LevelDB files 91 | *.sst 92 | *.ldb 93 | LOCK 94 | LOG* 95 | CURRENT 96 | MANIFEST-* 97 | 98 | # Ignore MKL files (except prepare_mkl.sh) 99 | /external/mkl/* 100 | !/external/mkl/prepare_mkl.sh 101 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | 4 | language: cpp 5 | compiler: gcc 6 | 7 | env: 8 | global: 9 | - NUM_THREADS=4 10 | matrix: 11 | # Use a build matrix to test many builds in parallel 12 | # envvar defaults: 13 | # WITH_CMAKE: false 14 | # WITH_PYTHON3: false 15 | # WITH_IO: true 16 | # WITH_CUDA: false 17 | # WITH_CUDNN: false 18 | - BUILD_NAME="default-make" 19 | # - BUILD_NAME="python3-make" WITH_PYTHON3=true 20 | - BUILD_NAME="no-io-make" WITH_IO=false 21 | - BUILD_NAME="cuda-make" WITH_CUDA=true 22 | - BUILD_NAME="cudnn-make" WITH_CUDA=true WITH_CUDNN=true 23 | 24 | - BUILD_NAME="default-cmake" WITH_CMAKE=true 25 | - BUILD_NAME="python3-cmake" WITH_CMAKE=true WITH_PYTHON3=true 26 | - BUILD_NAME="no-io-cmake" WITH_CMAKE=true WITH_IO=false 27 | - BUILD_NAME="cuda-cmake" WITH_CMAKE=true WITH_CUDA=true 28 | - BUILD_NAME="cudnn-cmake" WITH_CMAKE=true WITH_CUDA=true WITH_CUDNN=true 29 | 30 | cache: 31 | apt: true 32 | directories: 33 | - ~/protobuf3 34 | 35 | before_install: 36 | - source ./scripts/travis/defaults.sh 37 | 38 | install: 39 | - sudo -E ./scripts/travis/install-deps.sh 40 | - ./scripts/travis/setup-venv.sh ~/venv 41 | - source ~/venv/bin/activate 42 | - ./scripts/travis/install-python-deps.sh 43 | 44 | before_script: 45 | - ./scripts/travis/configure.sh 46 | 47 | script: 48 | - ./scripts/travis/build.sh 49 | - ./scripts/travis/test.sh 50 | 51 | notifications: 52 | # Emails are sent to the committer's git-configured email address by default, 53 | # but only if they have access to the repository. To enable Travis on your 54 | # public fork of Caffe, just go to travis-ci.org and flip the switch on for 55 | # your Caffe fork. To configure your git email address, use: 56 | # git config --global user.email me@example.com 57 | email: 58 | on_success: always 59 | on_failure: always 60 | 61 | # IRC notifications disabled by default. 62 | # Uncomment next 5 lines to send notifications to chat.freenode.net#caffe 63 | # irc: 64 | # channels: 65 | # - "chat.freenode.net#caffe" 66 | # template: 67 | # - "%{repository}/%{branch} (%{commit} - %{author}): %{message}" 68 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Issues 4 | 5 | Specific Caffe design and development issues, bugs, and feature requests are maintained by GitHub Issues. 6 | 7 | _Please do not post usage, installation, or modeling questions, or other requests for help to Issues._ 8 | Use the [caffe-users list](https://groups.google.com/forum/#!forum/caffe-users) instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe. 9 | 10 | When reporting a bug, it's most helpful to provide the following information, where applicable: 11 | 12 | * What steps reproduce the bug? 13 | * Can you reproduce the bug using the latest [master](https://github.com/BVLC/caffe/tree/master), compiled with the `DEBUG` make option? 14 | * What hardware and operating system/distribution are you running? 15 | * If the bug is a crash, provide the backtrace (usually printed by Caffe; always obtainable with `gdb`). 16 | 17 | Try to give your issue a title that is succinct and specific. The devs will rename issues as needed to keep track of them. 18 | 19 | ## Pull Requests 20 | 21 | Caffe welcomes all contributions. 22 | 23 | See the [contributing guide](http://caffe.berkeleyvision.org/development.html) for details. 24 | 25 | Briefly: read commit by commit, a PR should tell a clean, compelling story of _one_ improvement to Caffe. In particular: 26 | 27 | * A PR should do one clear thing that obviously improves Caffe, and nothing more. Making many smaller PRs is better than making one large PR; review effort is superlinear in the amount of code involved. 28 | * Similarly, each commit should be a small, atomic change representing one step in development. PRs should be made of many commits where appropriate. 29 | * Please do rewrite PR history to be clean rather than chronological. Within-PR bugfixes, style cleanups, reversions, etc. should be squashed and should not appear in merged PR history. 30 | * Anything nonobvious from the code should be explained in comments, commit messages, or the PR description, as appropriate. 31 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | 3 | Caffe is developed by a core set of BVLC members and the open-source community. 4 | 5 | We thank all of our [contributors](https://github.com/BVLC/caffe/graphs/contributors)! 6 | 7 | **For the detailed history of contributions** of a given file, try 8 | 9 | git blame file 10 | 11 | to see line-by-line credits and 12 | 13 | git log --follow file 14 | 15 | to see the change log even across renames and rewrites. 16 | 17 | Please refer to the [acknowledgements](http://caffe.berkeleyvision.org/#acknowledgements) on the Caffe site for further details. 18 | 19 | **Copyright** is held by the original contributor according to the versioning history; see LICENSE. 20 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | See http://caffe.berkeleyvision.org/installation.html for the latest 4 | installation instructions. 5 | 6 | Check the users group in case you need help: 7 | https://groups.google.com/forum/#!forum/caffe-users 8 | -------------------------------------------------------------------------------- /caffe.cloc: -------------------------------------------------------------------------------- 1 | Bourne Shell 2 | filter remove_matches ^\s*# 3 | filter remove_inline #.*$ 4 | extension sh 5 | script_exe sh 6 | C 7 | filter remove_matches ^\s*// 8 | filter call_regexp_common C 9 | filter remove_inline //.*$ 10 | extension c 11 | extension ec 12 | extension pgc 13 | C++ 14 | filter remove_matches ^\s*// 15 | filter remove_inline //.*$ 16 | filter call_regexp_common C 17 | extension C 18 | extension cc 19 | extension cpp 20 | extension cxx 21 | extension pcc 22 | C/C++ Header 23 | filter remove_matches ^\s*// 24 | filter call_regexp_common C 25 | filter remove_inline //.*$ 26 | extension H 27 | extension h 28 | extension hh 29 | extension hpp 30 | CUDA 31 | filter remove_matches ^\s*// 32 | filter remove_inline //.*$ 33 | filter call_regexp_common C 34 | extension cu 35 | Python 36 | filter remove_matches ^\s*# 37 | filter docstring_to_C 38 | filter call_regexp_common C 39 | filter remove_inline #.*$ 40 | extension py 41 | make 42 | filter remove_matches ^\s*# 43 | filter remove_inline #.*$ 44 | extension Gnumakefile 45 | extension Makefile 46 | extension am 47 | extension gnumakefile 48 | extension makefile 49 | filename Gnumakefile 50 | filename Makefile 51 | filename gnumakefile 52 | filename makefile 53 | script_exe make 54 | -------------------------------------------------------------------------------- /cmake/External/gflags.cmake: -------------------------------------------------------------------------------- 1 | if (NOT __GFLAGS_INCLUDED) # guard against multiple includes 2 | set(__GFLAGS_INCLUDED TRUE) 3 | 4 | # use the system-wide gflags if present 5 | find_package(GFlags) 6 | if (GFLAGS_FOUND) 7 | set(GFLAGS_EXTERNAL FALSE) 8 | else() 9 | # gflags will use pthreads if it's available in the system, so we must link with it 10 | find_package(Threads) 11 | 12 | # build directory 13 | set(gflags_PREFIX ${CMAKE_BINARY_DIR}/external/gflags-prefix) 14 | # install directory 15 | set(gflags_INSTALL ${CMAKE_BINARY_DIR}/external/gflags-install) 16 | 17 | # we build gflags statically, but want to link it into the caffe shared library 18 | # this requires position-independent code 19 | if (UNIX) 20 | set(GFLAGS_EXTRA_COMPILER_FLAGS "-fPIC") 21 | endif() 22 | 23 | set(GFLAGS_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${GFLAGS_EXTRA_COMPILER_FLAGS}) 24 | set(GFLAGS_C_FLAGS ${CMAKE_C_FLAGS} ${GFLAGS_EXTRA_COMPILER_FLAGS}) 25 | 26 | ExternalProject_Add(gflags 27 | PREFIX ${gflags_PREFIX} 28 | GIT_REPOSITORY "https://github.com/gflags/gflags.git" 29 | GIT_TAG "v2.1.2" 30 | UPDATE_COMMAND "" 31 | INSTALL_DIR ${gflags_INSTALL} 32 | CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 33 | -DCMAKE_INSTALL_PREFIX=${gflags_INSTALL} 34 | -DBUILD_SHARED_LIBS=OFF 35 | -DBUILD_STATIC_LIBS=ON 36 | -DBUILD_PACKAGING=OFF 37 | -DBUILD_TESTING=OFF 38 | -DBUILD_NC_TESTS=OFF 39 | -BUILD_CONFIG_TESTS=OFF 40 | -DINSTALL_HEADERS=ON 41 | -DCMAKE_C_FLAGS=${GFLAGS_C_FLAGS} 42 | -DCMAKE_CXX_FLAGS=${GFLAGS_CXX_FLAGS} 43 | LOG_DOWNLOAD 1 44 | LOG_INSTALL 1 45 | ) 46 | 47 | set(GFLAGS_FOUND TRUE) 48 | set(GFLAGS_INCLUDE_DIRS ${gflags_INSTALL}/include) 49 | set(GFLAGS_LIBRARIES ${gflags_INSTALL}/lib/libgflags.a ${CMAKE_THREAD_LIBS_INIT}) 50 | set(GFLAGS_LIBRARY_DIRS ${gflags_INSTALL}/lib) 51 | set(GFLAGS_EXTERNAL TRUE) 52 | 53 | list(APPEND external_project_dependencies gflags) 54 | endif() 55 | 56 | endif() 57 | -------------------------------------------------------------------------------- /cmake/External/glog.cmake: -------------------------------------------------------------------------------- 1 | # glog depends on gflags 2 | include("cmake/External/gflags.cmake") 3 | 4 | if (NOT __GLOG_INCLUDED) 5 | set(__GLOG_INCLUDED TRUE) 6 | 7 | # try the system-wide glog first 8 | find_package(Glog) 9 | if (GLOG_FOUND) 10 | set(GLOG_EXTERNAL FALSE) 11 | else() 12 | # fetch and build glog from github 13 | 14 | # build directory 15 | set(glog_PREFIX ${CMAKE_BINARY_DIR}/external/glog-prefix) 16 | # install directory 17 | set(glog_INSTALL ${CMAKE_BINARY_DIR}/external/glog-install) 18 | 19 | # we build glog statically, but want to link it into the caffe shared library 20 | # this requires position-independent code 21 | if (UNIX) 22 | set(GLOG_EXTRA_COMPILER_FLAGS "-fPIC") 23 | endif() 24 | 25 | set(GLOG_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${GLOG_EXTRA_COMPILER_FLAGS}) 26 | set(GLOG_C_FLAGS ${CMAKE_C_FLAGS} ${GLOG_EXTRA_COMPILER_FLAGS}) 27 | 28 | # depend on gflags if we're also building it 29 | if (GFLAGS_EXTERNAL) 30 | set(GLOG_DEPENDS gflags) 31 | endif() 32 | 33 | ExternalProject_Add(glog 34 | DEPENDS ${GLOG_DEPENDS} 35 | PREFIX ${glog_PREFIX} 36 | GIT_REPOSITORY "https://github.com/google/glog" 37 | GIT_TAG "v0.3.4" 38 | UPDATE_COMMAND "" 39 | INSTALL_DIR ${gflags_INSTALL} 40 | CONFIGURE_COMMAND env "CFLAGS=${GLOG_C_FLAGS}" "CXXFLAGS=${GLOG_CXX_FLAGS}" ${glog_PREFIX}/src/glog/configure --prefix=${glog_INSTALL} --enable-shared=no --enable-static=yes --with-gflags=${GFLAGS_LIBRARY_DIRS}/.. 41 | LOG_DOWNLOAD 1 42 | LOG_CONFIGURE 1 43 | LOG_INSTALL 1 44 | ) 45 | 46 | set(GLOG_FOUND TRUE) 47 | set(GLOG_INCLUDE_DIRS ${glog_INSTALL}/include) 48 | set(GLOG_LIBRARIES ${GFLAGS_LIBRARIES} ${glog_INSTALL}/lib/libglog.a) 49 | set(GLOG_LIBRARY_DIRS ${glog_INSTALL}/lib) 50 | set(GLOG_EXTERNAL TRUE) 51 | 52 | list(APPEND external_project_dependencies glog) 53 | endif() 54 | 55 | endif() 56 | 57 | -------------------------------------------------------------------------------- /cmake/MKLDNN.cmake: -------------------------------------------------------------------------------- 1 | 2 | function(Download_MKLDNN) 3 | set(EXTERNAL_DIR ${CMAKE_SOURCE_DIR}/external) 4 | set(MKLDNN_DIR ${EXTERNAL_DIR}/mkldnn) 5 | set(MKLDNN_SOURCE_DIR ${MKLDNN_DIR}/src) 6 | set(MKLDNN_BUILD_DIR ${MKLDNN_DIR}/build) 7 | set(MKLDNN_INSTALL_DIR ${MKLDNN_DIR}/install CACHE PATH "Installation path of MKLDNN") 8 | execute_process(COMMAND cat mkldnn.commit 9 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 10 | OUTPUT_VARIABLE MKLDNN_COMMIT) 11 | 12 | include(ProcessorCount) 13 | ProcessorCount(NCORE) 14 | if(NOT NCORE EQUAL 0) 15 | set(CTEST_BUILD_FLAGS -j${NCORE}) 16 | set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${NCORE}) 17 | endif() 18 | 19 | ExternalProject_add(MKLDNN_Build 20 | SOURCE_DIR ${MKLDNN_SOURCE_DIR} 21 | CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR} -DMKLROOT=${MKL_ROOT_DIR} 22 | #--Download step 23 | GIT_REPOSITORY https://github.com/01org/mkl-dnn.git 24 | GIT_TAG ${MKLDNN_COMMIT} 25 | #--Build step 26 | BINARY_DIR ${MKLDNN_BUILD_DIR} 27 | BUILD_COMMAND cmake ${MKLDNN_SOURCE_DIR} 28 | #--Install step 29 | INSTALL_DIR ${MKLDNN_INSTALL_DIR} 30 | INSTALL_COMMAND make install -j${NCORE} 31 | LOG_CONFIGURE 1 32 | LOG_BUILD 1 33 | LOG_INSTALL 1 34 | ) 35 | 36 | set(MKLDNN_INCLUDE_DIR ${MKLDNN_INSTALL_DIR}/include CACHE PATH "Include files for MKLDNN") 37 | set(MKLDNN_LIB_DIR ${MKLDNN_INSTALL_DIR}/lib) 38 | add_library(mkldnn SHARED IMPORTED ${MKLDNN_INSTALL_DIR}) 39 | set_property(TARGET mkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB_DIR}/libmkldnn.so) 40 | add_dependencies(mkldnn MKLDNN_Build) 41 | endfunction(Download_MKLDNN) 42 | -------------------------------------------------------------------------------- /cmake/Misc.cmake: -------------------------------------------------------------------------------- 1 | # ---[ Configuration types 2 | set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Possible configurations" FORCE) 3 | mark_as_advanced(CMAKE_CONFIGURATION_TYPES) 4 | 5 | if(DEFINED CMAKE_BUILD_TYPE) 6 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES}) 7 | endif() 8 | 9 | # --[ If user doesn't specify build type then assume release 10 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 11 | set(CMAKE_BUILD_TYPE Release) 12 | endif() 13 | 14 | if("${DETERMINISTIC}" STREQUAL "ON") 15 | add_definitions(-DDETERMINISTIC) 16 | endif() 17 | 18 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 19 | set(CMAKE_COMPILER_IS_CLANGXX TRUE) 20 | endif() 21 | 22 | # ---[ Solution folders 23 | caffe_option(USE_PROJECT_FOLDERS "IDE Solution folders" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) ) 24 | 25 | if(USE_PROJECT_FOLDERS) 26 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 27 | set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets") 28 | endif() 29 | 30 | # ---[ Install options 31 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 32 | set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "Default install path" FORCE) 33 | endif() 34 | 35 | # ---[ RPATH settings 36 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOLEAN "Use link paths for shared library rpath") 37 | set(CMAKE_MACOSX_RPATH TRUE) 38 | 39 | list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib __is_systtem_dir) 40 | if(${__is_systtem_dir} STREQUAL -1) 41 | set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) 42 | endif() 43 | 44 | # ---[ Funny target 45 | if(UNIX OR APPLE) 46 | add_custom_target(symlink_to_build COMMAND "ln" "-sf" "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/build" 47 | COMMENT "Adding symlink: /build -> ${PROJECT_BINARY_DIR}" ) 48 | endif() 49 | 50 | # ---[ Set debug postfix 51 | set(Caffe_DEBUG_POSTFIX "-d") 52 | 53 | set(Caffe_POSTFIX "") 54 | if(CMAKE_BUILD_TYPE MATCHES "Debug") 55 | set(Caffe_POSTFIX ${Caffe_DEBUG_POSTFIX}) 56 | endif() 57 | -------------------------------------------------------------------------------- /cmake/Modules/FindAtlas.cmake: -------------------------------------------------------------------------------- 1 | # Find the Atlas (and Lapack) libraries 2 | # 3 | # The following variables are optionally searched for defaults 4 | # Atlas_ROOT_DIR: Base directory where all Atlas components are found 5 | # 6 | # The following are set after configuration is done: 7 | # Atlas_FOUND 8 | # Atlas_INCLUDE_DIRS 9 | # Atlas_LIBRARIES 10 | # Atlas_LIBRARYRARY_DIRS 11 | 12 | set(Atlas_INCLUDE_SEARCH_PATHS 13 | /usr/include/atlas 14 | /usr/include/atlas-base 15 | $ENV{Atlas_ROOT_DIR} 16 | $ENV{Atlas_ROOT_DIR}/include 17 | ) 18 | 19 | set(Atlas_LIB_SEARCH_PATHS 20 | /usr/lib/atlas 21 | /usr/lib/atlas-base 22 | $ENV{Atlas_ROOT_DIR} 23 | $ENV{Atlas_ROOT_DIR}/lib 24 | ) 25 | 26 | find_path(Atlas_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS}) 27 | find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES clapack.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS}) 28 | 29 | find_library(Atlas_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS}) 30 | find_library(Atlas_BLAS_LIBRARY NAMES atlas_r atlas PATHS ${Atlas_LIB_SEARCH_PATHS}) 31 | find_library(Atlas_LAPACK_LIBRARY NAMES lapack alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS}) 32 | 33 | set(LOOKED_FOR 34 | Atlas_CBLAS_INCLUDE_DIR 35 | Atlas_CLAPACK_INCLUDE_DIR 36 | 37 | Atlas_CBLAS_LIBRARY 38 | Atlas_BLAS_LIBRARY 39 | Atlas_LAPACK_LIBRARY 40 | ) 41 | 42 | include(FindPackageHandleStandardArgs) 43 | find_package_handle_standard_args(Atlas DEFAULT_MSG ${LOOKED_FOR}) 44 | 45 | if(ATLAS_FOUND) 46 | set(Atlas_INCLUDE_DIR ${Atlas_CBLAS_INCLUDE_DIR} ${Atlas_CLAPACK_INCLUDE_DIR}) 47 | set(Atlas_LIBRARIES ${Atlas_LAPACK_LIBRARY} ${Atlas_CBLAS_LIBRARY} ${Atlas_BLAS_LIBRARY}) 48 | mark_as_advanced(${LOOKED_FOR}) 49 | 50 | message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})") 51 | endif(ATLAS_FOUND) 52 | 53 | -------------------------------------------------------------------------------- /cmake/Modules/FindGFlags.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find GFLAGS 2 | # 3 | # The following variables are optionally searched for defaults 4 | # GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found 5 | # 6 | # The following are set after configuration is done: 7 | # GFLAGS_FOUND 8 | # GFLAGS_INCLUDE_DIRS 9 | # GFLAGS_LIBRARIES 10 | # GFLAGS_LIBRARYRARY_DIRS 11 | 12 | include(FindPackageHandleStandardArgs) 13 | 14 | set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags") 15 | 16 | # We are testing only a couple of files in the include directories 17 | if(WIN32) 18 | find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h 19 | PATHS ${GFLAGS_ROOT_DIR}/src/windows) 20 | else() 21 | find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h 22 | PATHS ${GFLAGS_ROOT_DIR}) 23 | endif() 24 | 25 | if(MSVC) 26 | find_library(GFLAGS_LIBRARY_RELEASE 27 | NAMES libgflags 28 | PATHS ${GFLAGS_ROOT_DIR} 29 | PATH_SUFFIXES Release) 30 | 31 | find_library(GFLAGS_LIBRARY_DEBUG 32 | NAMES libgflags-debug 33 | PATHS ${GFLAGS_ROOT_DIR} 34 | PATH_SUFFIXES Debug) 35 | 36 | set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG}) 37 | else() 38 | find_library(GFLAGS_LIBRARY gflags) 39 | endif() 40 | 41 | find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) 42 | 43 | 44 | if(GFLAGS_FOUND) 45 | set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR}) 46 | set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY}) 47 | message(STATUS "Found gflags (include: ${GFLAGS_INCLUDE_DIR}, library: ${GFLAGS_LIBRARY})") 48 | mark_as_advanced(GFLAGS_LIBRARY_DEBUG GFLAGS_LIBRARY_RELEASE 49 | GFLAGS_LIBRARY GFLAGS_INCLUDE_DIR GFLAGS_ROOT_DIR) 50 | endif() 51 | -------------------------------------------------------------------------------- /cmake/Modules/FindGlog.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Glog 2 | # 3 | # The following variables are optionally searched for defaults 4 | # GLOG_ROOT_DIR: Base directory where all GLOG components are found 5 | # 6 | # The following are set after configuration is done: 7 | # GLOG_FOUND 8 | # GLOG_INCLUDE_DIRS 9 | # GLOG_LIBRARIES 10 | # GLOG_LIBRARYRARY_DIRS 11 | 12 | include(FindPackageHandleStandardArgs) 13 | 14 | set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog") 15 | 16 | if(WIN32) 17 | find_path(GLOG_INCLUDE_DIR glog/logging.h 18 | PATHS ${GLOG_ROOT_DIR}/src/windows) 19 | else() 20 | find_path(GLOG_INCLUDE_DIR glog/logging.h 21 | PATHS ${GLOG_ROOT_DIR}) 22 | endif() 23 | 24 | if(MSVC) 25 | find_library(GLOG_LIBRARY_RELEASE libglog_static 26 | PATHS ${GLOG_ROOT_DIR} 27 | PATH_SUFFIXES Release) 28 | 29 | find_library(GLOG_LIBRARY_DEBUG libglog_static 30 | PATHS ${GLOG_ROOT_DIR} 31 | PATH_SUFFIXES Debug) 32 | 33 | set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG}) 34 | else() 35 | find_library(GLOG_LIBRARY glog 36 | PATHS ${GLOG_ROOT_DIR} 37 | PATH_SUFFIXES lib lib64) 38 | endif() 39 | 40 | find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIR GLOG_LIBRARY) 41 | 42 | if(GLOG_FOUND) 43 | set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) 44 | set(GLOG_LIBRARIES ${GLOG_LIBRARY}) 45 | message(STATUS "Found glog (include: ${GLOG_INCLUDE_DIR}, library: ${GLOG_LIBRARY})") 46 | mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY_RELEASE GLOG_LIBRARY_DEBUG 47 | GLOG_LIBRARY GLOG_INCLUDE_DIR) 48 | endif() 49 | -------------------------------------------------------------------------------- /cmake/Modules/FindLMDB.cmake: -------------------------------------------------------------------------------- 1 | # Try to find the LMBD libraries and headers 2 | # LMDB_FOUND - system has LMDB lib 3 | # LMDB_INCLUDE_DIR - the LMDB include directory 4 | # LMDB_LIBRARIES - Libraries needed to use LMDB 5 | 6 | # FindCWD based on FindGMP by: 7 | # Copyright (c) 2006, Laurent Montel, 8 | # 9 | # Redistribution and use is allowed according to the terms of the BSD license. 10 | 11 | # Adapted from FindCWD by: 12 | # Copyright 2013 Conrad Steenberg 13 | # Aug 31, 2013 14 | 15 | find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "$ENV{LMDB_DIR}/include") 16 | find_library(LMDB_LIBRARIES NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" ) 17 | 18 | include(FindPackageHandleStandardArgs) 19 | find_package_handle_standard_args(LMDB DEFAULT_MSG LMDB_INCLUDE_DIR LMDB_LIBRARIES) 20 | 21 | if(LMDB_FOUND) 22 | message(STATUS "Found lmdb (include: ${LMDB_INCLUDE_DIR}, library: ${LMDB_LIBRARIES})") 23 | mark_as_advanced(LMDB_INCLUDE_DIR LMDB_LIBRARIES) 24 | 25 | caffe_parse_header(${LMDB_INCLUDE_DIR}/lmdb.h 26 | LMDB_VERSION_LINES MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_PATCH) 27 | set(LMDB_VERSION "${MDB_VERSION_MAJOR}.${MDB_VERSION_MINOR}.${MDB_VERSION_PATCH}") 28 | endif() 29 | -------------------------------------------------------------------------------- /cmake/Modules/FindLevelDB.cmake: -------------------------------------------------------------------------------- 1 | # - Find LevelDB 2 | # 3 | # LevelDB_INCLUDES - List of LevelDB includes 4 | # LevelDB_LIBRARIES - List of libraries when using LevelDB. 5 | # LevelDB_FOUND - True if LevelDB found. 6 | 7 | # Look for the header file. 8 | find_path(LevelDB_INCLUDE NAMES leveldb/db.h 9 | PATHS $ENV{LEVELDB_ROOT}/include /opt/local/include /usr/local/include /usr/include 10 | DOC "Path in which the file leveldb/db.h is located." ) 11 | 12 | # Look for the library. 13 | find_library(LevelDB_LIBRARY NAMES leveldb 14 | PATHS /usr/lib $ENV{LEVELDB_ROOT}/lib 15 | DOC "Path to leveldb library." ) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | find_package_handle_standard_args(LevelDB DEFAULT_MSG LevelDB_INCLUDE LevelDB_LIBRARY) 19 | 20 | if(LEVELDB_FOUND) 21 | message(STATUS "Found LevelDB (include: ${LevelDB_INCLUDE}, library: ${LevelDB_LIBRARY})") 22 | set(LevelDB_INCLUDES ${LevelDB_INCLUDE}) 23 | set(LevelDB_LIBRARIES ${LevelDB_LIBRARY}) 24 | mark_as_advanced(LevelDB_INCLUDE LevelDB_LIBRARY) 25 | 26 | if(EXISTS "${LevelDB_INCLUDE}/leveldb/db.h") 27 | file(STRINGS "${LevelDB_INCLUDE}/leveldb/db.h" __version_lines 28 | REGEX "static const int k[^V]+Version[ \t]+=[ \t]+[0-9]+;") 29 | 30 | foreach(__line ${__version_lines}) 31 | if(__line MATCHES "[^k]+kMajorVersion[ \t]+=[ \t]+([0-9]+);") 32 | set(LEVELDB_VERSION_MAJOR ${CMAKE_MATCH_1}) 33 | elseif(__line MATCHES "[^k]+kMinorVersion[ \t]+=[ \t]+([0-9]+);") 34 | set(LEVELDB_VERSION_MINOR ${CMAKE_MATCH_1}) 35 | endif() 36 | endforeach() 37 | 38 | if(LEVELDB_VERSION_MAJOR AND LEVELDB_VERSION_MINOR) 39 | set(LEVELDB_VERSION "${LEVELDB_VERSION_MAJOR}.${LEVELDB_VERSION_MINOR}") 40 | endif() 41 | 42 | caffe_clear_vars(__line __version_lines) 43 | endif() 44 | endif() 45 | -------------------------------------------------------------------------------- /cmake/Modules/FindMatlabMex.cmake: -------------------------------------------------------------------------------- 1 | # This module looks for MatlabMex compiler 2 | # Defines variables: 3 | # Matlab_DIR - Matlab root dir 4 | # Matlab_mex - path to mex compiler 5 | # Matlab_mexext - path to mexext 6 | 7 | if(MSVC) 8 | foreach(__ver "9.30" "7.14" "7.11" "7.10" "7.9" "7.8" "7.7") 9 | get_filename_component(__matlab_root "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\${__ver};MATLABROOT]" ABSOLUTE) 10 | if(__matlab_root) 11 | break() 12 | endif() 13 | endforeach() 14 | endif() 15 | 16 | if(APPLE) 17 | foreach(__ver "R2014b" "R2014a" "R2013b" "R2013a" "R2012b" "R2012a" "R2011b" "R2011a" "R2010b" "R2010a") 18 | if(EXISTS /Applications/MATLAB_${__ver}.app) 19 | set(__matlab_root /Applications/MATLAB_${__ver}.app) 20 | break() 21 | endif() 22 | endforeach() 23 | endif() 24 | 25 | if(UNIX) 26 | execute_process(COMMAND which matlab OUTPUT_STRIP_TRAILING_WHITESPACE 27 | OUTPUT_VARIABLE __out RESULT_VARIABLE __res) 28 | 29 | if(__res MATCHES 0) # Suppress `readlink` warning if `which` returned nothing 30 | execute_process(COMMAND which matlab COMMAND xargs readlink 31 | COMMAND xargs dirname COMMAND xargs dirname COMMAND xargs echo -n 32 | OUTPUT_VARIABLE __matlab_root OUTPUT_STRIP_TRAILING_WHITESPACE) 33 | endif() 34 | endif() 35 | 36 | 37 | find_path(Matlab_DIR NAMES bin/mex bin/mexext PATHS ${__matlab_root} 38 | DOC "Matlab directory" NO_DEFAULT_PATH) 39 | 40 | find_program(Matlab_mex NAMES mex mex.bat HINTS ${Matlab_DIR} PATH_SUFFIXES bin NO_DEFAULT_PATH) 41 | find_program(Matlab_mexext NAMES mexext mexext.bat HINTS ${Matlab_DIR} PATH_SUFFIXES bin NO_DEFAULT_PATH) 42 | 43 | include(FindPackageHandleStandardArgs) 44 | find_package_handle_standard_args(MatlabMex DEFAULT_MSG Matlab_mex Matlab_mexext) 45 | 46 | if(MATLABMEX_FOUND) 47 | mark_as_advanced(Matlab_mex Matlab_mexext) 48 | endif() 49 | -------------------------------------------------------------------------------- /cmake/Modules/FindOpenBLAS.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | SET(Open_BLAS_INCLUDE_SEARCH_PATHS 4 | /usr/include 5 | /usr/include/openblas 6 | /usr/include/openblas-base 7 | /usr/local/include 8 | /usr/local/include/openblas 9 | /usr/local/include/openblas-base 10 | /opt/OpenBLAS/include 11 | $ENV{OpenBLAS_HOME} 12 | $ENV{OpenBLAS_HOME}/include 13 | ) 14 | 15 | SET(Open_BLAS_LIB_SEARCH_PATHS 16 | /lib/ 17 | /lib/openblas-base 18 | /lib64/ 19 | /usr/lib 20 | /usr/lib/openblas-base 21 | /usr/lib64 22 | /usr/local/lib 23 | /usr/local/lib64 24 | /opt/OpenBLAS/lib 25 | $ENV{OpenBLAS}cd 26 | $ENV{OpenBLAS}/lib 27 | $ENV{OpenBLAS_HOME} 28 | $ENV{OpenBLAS_HOME}/lib 29 | ) 30 | 31 | FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS}) 32 | FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS}) 33 | 34 | SET(OpenBLAS_FOUND ON) 35 | 36 | # Check include files 37 | IF(NOT OpenBLAS_INCLUDE_DIR) 38 | SET(OpenBLAS_FOUND OFF) 39 | MESSAGE(STATUS "Could not find OpenBLAS include. Turning OpenBLAS_FOUND off") 40 | ENDIF() 41 | 42 | # Check libraries 43 | IF(NOT OpenBLAS_LIB) 44 | SET(OpenBLAS_FOUND OFF) 45 | MESSAGE(STATUS "Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off") 46 | ENDIF() 47 | 48 | IF (OpenBLAS_FOUND) 49 | IF (NOT OpenBLAS_FIND_QUIETLY) 50 | MESSAGE(STATUS "Found OpenBLAS libraries: ${OpenBLAS_LIB}") 51 | MESSAGE(STATUS "Found OpenBLAS include: ${OpenBLAS_INCLUDE_DIR}") 52 | ENDIF (NOT OpenBLAS_FIND_QUIETLY) 53 | ELSE (OpenBLAS_FOUND) 54 | IF (OpenBLAS_FIND_REQUIRED) 55 | MESSAGE(FATAL_ERROR "Could not find OpenBLAS") 56 | ENDIF (OpenBLAS_FIND_REQUIRED) 57 | ENDIF (OpenBLAS_FOUND) 58 | 59 | MARK_AS_ADVANCED( 60 | OpenBLAS_INCLUDE_DIR 61 | OpenBLAS_LIB 62 | OpenBLAS 63 | ) 64 | 65 | -------------------------------------------------------------------------------- /cmake/Modules/FindSnappy.cmake: -------------------------------------------------------------------------------- 1 | # Find the Snappy libraries 2 | # 3 | # The following variables are optionally searched for defaults 4 | # Snappy_ROOT_DIR: Base directory where all Snappy components are found 5 | # 6 | # The following are set after configuration is done: 7 | # SNAPPY_FOUND 8 | # Snappy_INCLUDE_DIR 9 | # Snappy_LIBRARIES 10 | 11 | find_path(Snappy_INCLUDE_DIR NAMES snappy.h 12 | PATHS ${SNAPPY_ROOT_DIR} ${SNAPPY_ROOT_DIR}/include) 13 | 14 | find_library(Snappy_LIBRARIES NAMES snappy 15 | PATHS ${SNAPPY_ROOT_DIR} ${SNAPPY_ROOT_DIR}/lib) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | find_package_handle_standard_args(Snappy DEFAULT_MSG Snappy_INCLUDE_DIR Snappy_LIBRARIES) 19 | 20 | if(SNAPPY_FOUND) 21 | message(STATUS "Found Snappy (include: ${Snappy_INCLUDE_DIR}, library: ${Snappy_LIBRARIES})") 22 | mark_as_advanced(Snappy_INCLUDE_DIR Snappy_LIBRARIES) 23 | 24 | caffe_parse_header(${Snappy_INCLUDE_DIR}/snappy-stubs-public.h 25 | SNAPPY_VERION_LINES SNAPPY_MAJOR SNAPPY_MINOR SNAPPY_PATCHLEVEL) 26 | set(Snappy_VERSION "${SNAPPY_MAJOR}.${SNAPPY_MINOR}.${SNAPPY_PATCHLEVEL}") 27 | endif() 28 | 29 | -------------------------------------------------------------------------------- /cmake/Modules/FindvecLib.cmake: -------------------------------------------------------------------------------- 1 | # Find the vecLib libraries as part of Accelerate.framework or as standalon framework 2 | # 3 | # The following are set after configuration is done: 4 | # VECLIB_FOUND 5 | # vecLib_INCLUDE_DIR 6 | # vecLib_LINKER_LIBS 7 | 8 | 9 | if(NOT APPLE) 10 | return() 11 | endif() 12 | 13 | set(__veclib_include_suffix "Frameworks/vecLib.framework/Versions/Current/Headers") 14 | 15 | find_path(vecLib_INCLUDE_DIR vecLib.h 16 | DOC "vecLib include directory" 17 | PATHS /System/Library/${__veclib_include_suffix} 18 | /System/Library/Frameworks/Accelerate.framework/Versions/Current/${__veclib_include_suffix} 19 | /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/) 20 | 21 | include(FindPackageHandleStandardArgs) 22 | find_package_handle_standard_args(vecLib DEFAULT_MSG vecLib_INCLUDE_DIR) 23 | 24 | if(VECLIB_FOUND) 25 | if(vecLib_INCLUDE_DIR MATCHES "^/System/Library/Frameworks/vecLib.framework.*") 26 | set(vecLib_LINKER_LIBS -lcblas "-framework vecLib") 27 | message(STATUS "Found standalone vecLib.framework") 28 | else() 29 | set(vecLib_LINKER_LIBS -lcblas "-framework Accelerate") 30 | message(STATUS "Found vecLib as part of Accelerate.framework") 31 | endif() 32 | 33 | mark_as_advanced(vecLib_INCLUDE_DIR) 34 | endif() 35 | -------------------------------------------------------------------------------- /cmake/Templates/CaffeConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # Config file for the Caffe package. 2 | # 3 | # Note: 4 | # Caffe and this config file depends on opencv, 5 | # so put `find_package(OpenCV)` before searching Caffe 6 | # via `find_package(Caffe)`. All other lib/includes 7 | # dependencies are hard coded in the file 8 | # 9 | # After successful configuration the following variables 10 | # will be defined: 11 | # 12 | # Caffe_INCLUDE_DIRS - Caffe include directories 13 | # Caffe_LIBRARIES - libraries to link against 14 | # Caffe_DEFINITIONS - a list of definitions to pass to compiler 15 | # 16 | # Caffe_HAVE_CUDA - signals about CUDA support 17 | # Caffe_HAVE_CUDNN - signals about cuDNN support 18 | 19 | 20 | # OpenCV dependency (optional) 21 | 22 | if(@USE_OPENCV@) 23 | if(NOT OpenCV_FOUND) 24 | set(Caffe_OpenCV_CONFIG_PATH "@OpenCV_CONFIG_PATH@") 25 | if(Caffe_OpenCV_CONFIG_PATH) 26 | get_filename_component(Caffe_OpenCV_CONFIG_PATH ${Caffe_OpenCV_CONFIG_PATH} ABSOLUTE) 27 | 28 | if(EXISTS ${Caffe_OpenCV_CONFIG_PATH} AND NOT TARGET opencv_core) 29 | message(STATUS "Caffe: using OpenCV config from ${Caffe_OpenCV_CONFIG_PATH}") 30 | include(${Caffe_OpenCV_CONFIG_PATH}/OpenCVModules.cmake) 31 | endif() 32 | 33 | else() 34 | find_package(OpenCV REQUIRED) 35 | endif() 36 | unset(Caffe_OpenCV_CONFIG_PATH) 37 | endif() 38 | endif() 39 | 40 | # Compute paths 41 | get_filename_component(Caffe_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 42 | set(Caffe_INCLUDE_DIRS "@Caffe_INCLUDE_DIRS@") 43 | 44 | @Caffe_INSTALL_INCLUDE_DIR_APPEND_COMMAND@ 45 | 46 | # Our library dependencies 47 | if(NOT TARGET caffe AND NOT caffe_BINARY_DIR) 48 | include("${Caffe_CMAKE_DIR}/CaffeTargets.cmake") 49 | endif() 50 | 51 | # List of IMPORTED libs created by CaffeTargets.cmake 52 | set(Caffe_LIBRARIES caffe) 53 | 54 | # Definitions 55 | set(Caffe_DEFINITIONS "@Caffe_DEFINITIONS@") 56 | 57 | # Cuda support variables 58 | set(Caffe_CPU_ONLY @CPU_ONLY@) 59 | set(Caffe_HAVE_CUDA @HAVE_CUDA@) 60 | set(Caffe_HAVE_CUDNN @HAVE_CUDNN@) 61 | -------------------------------------------------------------------------------- /cmake/Templates/CaffeConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@Caffe_VERSION@") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Templates/caffe_config.h.in: -------------------------------------------------------------------------------- 1 | /* Sources directory */ 2 | #define SOURCE_FOLDER "${PROJECT_SOURCE_DIR}" 3 | 4 | /* Binaries directory */ 5 | #define BINARY_FOLDER "${PROJECT_BINARY_DIR}" 6 | 7 | /* NVIDA Cuda */ 8 | #cmakedefine HAVE_CUDA 9 | 10 | /* NVIDA cuDNN */ 11 | #cmakedefine HAVE_CUDNN 12 | #cmakedefine USE_CUDNN 13 | 14 | /* NVIDA cuDNN */ 15 | #cmakedefine CPU_ONLY 16 | 17 | /* Test device */ 18 | #define CUDA_TEST_DEVICE ${CUDA_TEST_DEVICE} 19 | 20 | /* Temporary (TODO: remove) */ 21 | #if 1 22 | #define CMAKE_SOURCE_DIR SOURCE_FOLDER "/src/" 23 | #define EXAMPLES_SOURCE_DIR BINARY_FOLDER "/examples/" 24 | #define CMAKE_EXT ".gen.cmake" 25 | #else 26 | #define CMAKE_SOURCE_DIR "src/" 27 | #define EXAMPLES_SOURCE_DIR "examples/" 28 | #define CMAKE_EXT "" 29 | #endif 30 | 31 | /* Matlab */ 32 | #cmakedefine HAVE_MATLAB 33 | 34 | /* IO libraries */ 35 | #cmakedefine USE_OPENCV 36 | #cmakedefine USE_LEVELDB 37 | #cmakedefine USE_LMDB 38 | #cmakedefine ALLOW_LMDB_NOLOCK 39 | -------------------------------------------------------------------------------- /cmake/lint.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_SOURCE_DIR ..) 3 | set(LINT_COMMAND ${CMAKE_SOURCE_DIR}/scripts/cpp_lint.py) 4 | set(SRC_FILE_EXTENSIONS h hpp hu c cpp cu cc) 5 | set(EXCLUDE_FILE_EXTENSTIONS pb.h pb.cc) 6 | set(LINT_DIRS include src/caffe examples tools python matlab) 7 | 8 | cmake_policy(SET CMP0009 NEW) # suppress cmake warning 9 | 10 | # find all files of interest 11 | foreach(ext ${SRC_FILE_EXTENSIONS}) 12 | foreach(dir ${LINT_DIRS}) 13 | file(GLOB_RECURSE FOUND_FILES ${CMAKE_SOURCE_DIR}/${dir}/*.${ext}) 14 | set(LINT_SOURCES ${LINT_SOURCES} ${FOUND_FILES}) 15 | endforeach() 16 | endforeach() 17 | 18 | # find all files that should be excluded 19 | foreach(ext ${EXCLUDE_FILE_EXTENSTIONS}) 20 | file(GLOB_RECURSE FOUND_FILES ${CMAKE_SOURCE_DIR}/*.${ext}) 21 | set(EXCLUDED_FILES ${EXCLUDED_FILES} ${FOUND_FILES}) 22 | endforeach() 23 | 24 | # exclude generated pb files 25 | list(REMOVE_ITEM LINT_SOURCES ${EXCLUDED_FILES}) 26 | 27 | execute_process( 28 | COMMAND ${LINT_COMMAND} ${LINT_SOURCES} 29 | ERROR_VARIABLE LINT_OUTPUT 30 | ERROR_STRIP_TRAILING_WHITESPACE 31 | ) 32 | 33 | string(REPLACE "\n" ";" LINT_OUTPUT ${LINT_OUTPUT}) 34 | 35 | list(GET LINT_OUTPUT -1 LINT_RESULT) 36 | list(REMOVE_AT LINT_OUTPUT -1) 37 | string(REPLACE " " ";" LINT_RESULT ${LINT_RESULT}) 38 | list(GET LINT_RESULT -1 NUM_ERRORS) 39 | if(NUM_ERRORS GREATER 0) 40 | foreach(msg ${LINT_OUTPUT}) 41 | string(FIND ${msg} "Done" result) 42 | if(result LESS 0) 43 | message(STATUS ${msg}) 44 | endif() 45 | endforeach() 46 | message(FATAL_ERROR "Lint found ${NUM_ERRORS} errors!") 47 | else() 48 | message(STATUS "Lint did not find any errors!") 49 | endif() 50 | 51 | -------------------------------------------------------------------------------- /data/VOC0712/coco_voc_map.txt: -------------------------------------------------------------------------------- 1 | 0,0,background 2 | 5,1,aeroplane 3 | 2,2,bicycle 4 | 15,3,bird 5 | 9,4,boat 6 | 40,5,bottle 7 | 6,6,bus 8 | 3,7,car 9 | 16,8,cat 10 | 57,9,chair 11 | 20,10,cow 12 | 61,11,diningtable 13 | 17,12,dog 14 | 18,13,horse 15 | 4,14,motorbike 16 | 1,15,person 17 | 59,16,pottedplant 18 | 19,17,sheep 19 | 58,18,sofa 20 | 7,19,train 21 | 63,20,tvmonitor 22 | -------------------------------------------------------------------------------- /data/VOC0712/create_data.sh: -------------------------------------------------------------------------------- 1 | cur_dir=$(cd $( dirname ${BASH_SOURCE[0]} ) && pwd ) 2 | root_dir=$cur_dir/../.. 3 | 4 | cd $root_dir 5 | 6 | redo=1 7 | data_root_dir="$DATAPATH/data/VOCdevkit" 8 | dataset_name="VOC0712" 9 | mapfile="$root_dir/data/$dataset_name/labelmap_voc.prototxt" 10 | anno_type="detection" 11 | db="lmdb" 12 | min_dim=0 13 | max_dim=0 14 | width=0 15 | height=0 16 | 17 | extra_cmd="--encode-type=jpg --encoded" 18 | if [ $redo ] 19 | then 20 | extra_cmd="$extra_cmd --redo" 21 | fi 22 | for subset in test trainval 23 | do 24 | python $root_dir/scripts/create_annoset.py --anno-type=$anno_type --label-map-file=$mapfile --min-dim=$min_dim --max-dim=$max_dim --resize-width=$width --resize-height=$height --check-label $extra_cmd $data_root_dir $root_dir/data/$dataset_name/$subset.txt $data_root_dir/$dataset_name/$db/$dataset_name"_"$subset"_"$db examples/$dataset_name 25 | done 26 | -------------------------------------------------------------------------------- /data/VOC0712/create_list.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | root_dir="$DATAPATH/data/VOCdevkit" 4 | sub_dir=ImageSets/Main 5 | bash_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | for dataset in trainval test 7 | do 8 | dst_file=$bash_dir/$dataset.txt 9 | if [ -f $dst_file ] 10 | then 11 | rm -f $dst_file 12 | fi 13 | for name in VOC2007 VOC2012 14 | do 15 | if [[ $dataset == "test" && $name == "VOC2012" ]] 16 | then 17 | continue 18 | fi 19 | echo "Create list for $name $dataset..." 20 | dataset_file=$root_dir/$name/$sub_dir/$dataset.txt 21 | 22 | img_file=$bash_dir/$dataset"_img.txt" 23 | cp $dataset_file $img_file 24 | sed -i "s/^/$name\/JPEGImages\//g" $img_file 25 | sed -i "s/$/.jpg/g" $img_file 26 | 27 | label_file=$bash_dir/$dataset"_label.txt" 28 | cp $dataset_file $label_file 29 | sed -i "s/^/$name\/Annotations\//g" $label_file 30 | sed -i "s/$/.xml/g" $label_file 31 | 32 | paste -d' ' $img_file $label_file >> $dst_file 33 | 34 | rm -f $label_file 35 | rm -f $img_file 36 | done 37 | 38 | # Generate image name and size infomation. 39 | if [ $dataset == "test" ] 40 | then 41 | $bash_dir/../../build/tools/get_image_size $root_dir $dst_file $bash_dir/$dataset"_name_size.txt" 42 | fi 43 | 44 | # Shuffle trainval file. 45 | if [ $dataset == "trainval" ] 46 | then 47 | rand_file=$dst_file.random 48 | cat $dst_file | perl -MList::Util=shuffle -e 'print shuffle();' > $rand_file 49 | mv $rand_file $dst_file 50 | fi 51 | done 52 | -------------------------------------------------------------------------------- /data/VOC0712/labelmap_voc.prototxt: -------------------------------------------------------------------------------- 1 | item { 2 | name: "none_of_the_above" 3 | label: 0 4 | display_name: "background" 5 | } 6 | item { 7 | name: "aeroplane" 8 | label: 1 9 | display_name: "aeroplane" 10 | } 11 | item { 12 | name: "bicycle" 13 | label: 2 14 | display_name: "bicycle" 15 | } 16 | item { 17 | name: "bird" 18 | label: 3 19 | display_name: "bird" 20 | } 21 | item { 22 | name: "boat" 23 | label: 4 24 | display_name: "boat" 25 | } 26 | item { 27 | name: "bottle" 28 | label: 5 29 | display_name: "bottle" 30 | } 31 | item { 32 | name: "bus" 33 | label: 6 34 | display_name: "bus" 35 | } 36 | item { 37 | name: "car" 38 | label: 7 39 | display_name: "car" 40 | } 41 | item { 42 | name: "cat" 43 | label: 8 44 | display_name: "cat" 45 | } 46 | item { 47 | name: "chair" 48 | label: 9 49 | display_name: "chair" 50 | } 51 | item { 52 | name: "cow" 53 | label: 10 54 | display_name: "cow" 55 | } 56 | item { 57 | name: "diningtable" 58 | label: 11 59 | display_name: "diningtable" 60 | } 61 | item { 62 | name: "dog" 63 | label: 12 64 | display_name: "dog" 65 | } 66 | item { 67 | name: "horse" 68 | label: 13 69 | display_name: "horse" 70 | } 71 | item { 72 | name: "motorbike" 73 | label: 14 74 | display_name: "motorbike" 75 | } 76 | item { 77 | name: "person" 78 | label: 15 79 | display_name: "person" 80 | } 81 | item { 82 | name: "pottedplant" 83 | label: 16 84 | display_name: "pottedplant" 85 | } 86 | item { 87 | name: "sheep" 88 | label: 17 89 | display_name: "sheep" 90 | } 91 | item { 92 | name: "sofa" 93 | label: 18 94 | display_name: "sofa" 95 | } 96 | item { 97 | name: "train" 98 | label: 19 99 | display_name: "train" 100 | } 101 | item { 102 | name: "tvmonitor" 103 | label: 20 104 | display_name: "tvmonitor" 105 | } 106 | -------------------------------------------------------------------------------- /data/cifar10/get_cifar10.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This scripts downloads the CIFAR10 (binary version) data and unzips it. 3 | 4 | DIR="$( cd "$(dirname "$0")" ; pwd -P )" 5 | cd "$DIR" 6 | 7 | echo "Downloading..." 8 | 9 | wget --no-check-certificate http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz 10 | 11 | echo "Unzipping..." 12 | 13 | tar -xf cifar-10-binary.tar.gz && rm -f cifar-10-binary.tar.gz 14 | mv cifar-10-batches-bin/* . && rm -rf cifar-10-batches-bin 15 | 16 | # Creation is split out because leveldb sometimes causes segfault 17 | # and needs to be re-created. 18 | 19 | echo "Done." 20 | -------------------------------------------------------------------------------- /data/coco/README.md: -------------------------------------------------------------------------------- 1 | ### Preparation 2 | 1. Download Images and Annotations from [MSCOCO](http://mscoco.org/dataset/#download). By default, we assume the data is stored in `$DATAPATH/data/coco` 3 | make sure extracted image directories (train2014, val2014 test2015) are inside 4 | '/images/' directory next to Annotations directory. 5 | And download also: 6 | http://www.cs.berkeley.edu/~rbg/faster-rcnn-data/instances_minival2014.json.zip 7 | http://www.cs.berkeley.edu/~rbg/faster-rcnn-data/instances_valminusminival2014.json.zip 8 | unzip instances_minival2014.json.zip 9 | unzip instances_valminusminival2014.json.zip 10 | mv instances_minival2014.json instances_valminusminival2014.json ./coco/annotations/ 11 | 2. Get the coco code. We will call the directory that you cloned coco into `$COCO_ROOT` 12 | ```Shell 13 | git clone https://github.com/weiliu89/coco.git 14 | cd coco 15 | git checkout dev 16 | git apply $CAFFE_ROOT/data/coco/diff.patch 17 | ``` 18 | 19 | 3. Build the coco code. 20 | ```Shell 21 | cd PythonAPI 22 | python setup.py build_ext --inplace 23 | ``` 24 | 25 | 4. Split the annotation to many files per image and get the image size info. 26 | ```Shell 27 | # Check scripts/batch_split_annotation.py and change settings accordingly. 28 | python scripts/batch_split_annotation.py 29 | # Create the minival2014_name_size.txt and test-dev2015_name_size.txt in $CAFFE_ROOT/data/coco 30 | python scripts/batch_get_image_size.py 31 | ``` 32 | 33 | 5. Create the LMDB file. 34 | ```Shell 35 | cd $CAFFE_ROOT 36 | # Create the minival.txt, testdev.txt, test.txt, train.txt in data/coco/ 37 | python data/coco/create_list.py 38 | # You can modify the parameters in create_data.sh if needed. 39 | # It will create lmdb files for minival, testdev, test, and train with encoded original image: 40 | # - $DATAPATH/data/coco/lmdb/coco_minival_lmdb 41 | # - $DATAPATH/data/coco/lmdb/coco_testdev_lmdb 42 | # - $DATAPATH/data/coco/lmdb/coco_test_lmdb 43 | # - $DATAPATH/data/coco/lmdb/coco_train_lmdb 44 | # and make soft links at examples/coco/ 45 | ./data/coco/create_data.sh 46 | ``` 47 | -------------------------------------------------------------------------------- /data/coco/create_data.sh: -------------------------------------------------------------------------------- 1 | cur_dir=$(cd $( dirname ${BASH_SOURCE[0]} ) && pwd ) 2 | root_dir=$cur_dir/../.. 3 | 4 | cd $root_dir 5 | 6 | redo=false 7 | data_root_dir="$DATAPATH/data/coco" 8 | dataset_name="coco" 9 | mapfile="$root_dir/data/$dataset_name/labelmap_coco.prototxt" 10 | anno_type="detection" 11 | label_type="json" 12 | db="lmdb" 13 | min_dim=0 14 | max_dim=0 15 | width=0 16 | height=0 17 | 18 | extra_cmd="--encode-type=jpg --encoded" 19 | if $redo 20 | then 21 | extra_cmd="$extra_cmd --redo" 22 | fi 23 | for subset in minival testdev train test 24 | do 25 | python $root_dir/scripts/create_annoset.py --anno-type=$anno_type --label-type=$label_type --label-map-file=$mapfile --min-dim=$min_dim --max-dim=$max_dim --resize-width=$width --resize-height=$height --check-label $extra_cmd $data_root_dir $root_dir/data/$dataset_name/$subset.txt $data_root_dir/$db/$dataset_name"_"$subset"_"$db examples/$dataset_name 2>&1 | tee $root_dir/data/$dataset_name/$subset.log 26 | done 27 | -------------------------------------------------------------------------------- /data/coco/labels.txt: -------------------------------------------------------------------------------- 1 | 1,1,person 2 | 2,2,bicycle 3 | 3,3,car 4 | 4,4,motorcycle 5 | 5,5,airplane 6 | 6,6,bus 7 | 7,7,train 8 | 8,8,truck 9 | 9,9,boat 10 | 10,10,traffic light 11 | 11,11,fire hydrant 12 | 13,12,stop sign 13 | 14,13,parking meter 14 | 15,14,bench 15 | 16,15,bird 16 | 17,16,cat 17 | 18,17,dog 18 | 19,18,horse 19 | 20,19,sheep 20 | 21,20,cow 21 | 22,21,elephant 22 | 23,22,bear 23 | 24,23,zebra 24 | 25,24,giraffe 25 | 27,25,backpack 26 | 28,26,umbrella 27 | 31,27,handbag 28 | 32,28,tie 29 | 33,29,suitcase 30 | 34,30,frisbee 31 | 35,31,skis 32 | 36,32,snowboard 33 | 37,33,sports ball 34 | 38,34,kite 35 | 39,35,baseball bat 36 | 40,36,baseball glove 37 | 41,37,skateboard 38 | 42,38,surfboard 39 | 43,39,tennis racket 40 | 44,40,bottle 41 | 46,41,wine glass 42 | 47,42,cup 43 | 48,43,fork 44 | 49,44,knife 45 | 50,45,spoon 46 | 51,46,bowl 47 | 52,47,banana 48 | 53,48,apple 49 | 54,49,sandwich 50 | 55,50,orange 51 | 56,51,broccoli 52 | 57,52,carrot 53 | 58,53,hot dog 54 | 59,54,pizza 55 | 60,55,donut 56 | 61,56,cake 57 | 62,57,chair 58 | 63,58,couch 59 | 64,59,potted plant 60 | 65,60,bed 61 | 67,61,dining table 62 | 70,62,toilet 63 | 72,63,tv 64 | 73,64,laptop 65 | 74,65,mouse 66 | 75,66,remote 67 | 76,67,keyboard 68 | 77,68,cell phone 69 | 78,69,microwave 70 | 79,70,oven 71 | 80,71,toaster 72 | 81,72,sink 73 | 82,73,refrigerator 74 | 84,74,book 75 | 85,75,clock 76 | 86,76,vase 77 | 87,77,scissors 78 | 88,78,teddy bear 79 | 89,79,hair drier 80 | 90,80,toothbrush 81 | -------------------------------------------------------------------------------- /data/ilsvrc12/get_ilsvrc_aux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # 3 | # N.B. This does not download the ilsvrcC12 data set, as it is gargantuan. 4 | # This script downloads the imagenet example auxiliary files including: 5 | # - the ilsvrc12 image mean, binaryproto 6 | # - synset ids and words 7 | # - Python pickle-format data of ImageNet graph structure and relative infogain 8 | # - the training splits with labels 9 | 10 | DIR="$( cd "$(dirname "$0")" ; pwd -P )" 11 | cd "$DIR" 12 | 13 | echo "Downloading..." 14 | 15 | wget -c http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz 16 | 17 | echo "Unzipping..." 18 | 19 | tar -xf caffe_ilsvrc12.tar.gz && rm -f caffe_ilsvrc12.tar.gz 20 | 21 | echo "Done." 22 | -------------------------------------------------------------------------------- /data/mnist/get_mnist.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This scripts downloads the mnist data and unzips it. 3 | 4 | DIR="$( cd "$(dirname "$0")" ; pwd -P )" 5 | cd "$DIR" 6 | 7 | echo "Downloading..." 8 | 9 | for fname in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte 10 | do 11 | if [ ! -e $fname ]; then 12 | wget --no-check-certificate http://yann.lecun.com/exdb/mnist/${fname}.gz 13 | gunzip ${fname}.gz 14 | fi 15 | done 16 | -------------------------------------------------------------------------------- /docker/Makefile: -------------------------------------------------------------------------------- 1 | # A makefile to build the docker images for caffe. 2 | # Three caffe images can be built: 3 | # caffe:cpu-centos --> A CPU-only build of caffe in CentOS-based image. 4 | # caffe:cpu-ubuntu --> A CPU-only build of caffe in Ubuntu-based image. 5 | # caffe:gpu --> A GPU-enabled build using the latest CUDA and CUDNN versions. 6 | 7 | DOCKER ?= docker 8 | 9 | ifneq ($(http_proxy),) 10 | DOCKER_BUILD_ARG += --build-arg http_proxy=$(http_proxy) 11 | endif 12 | ifneq ($(https_proxy),) 13 | DOCKER_BUILD_ARG += --build-arg https_proxy=$(https_proxy) 14 | endif 15 | 16 | 17 | all: docker_files standalone 18 | 19 | .PHONY: standalone devel 20 | 21 | cpu_standalone: cpu-centos cpu-ubuntu 22 | standalone: cpu_standalone gpu_standalone 23 | 24 | cpu-centos: standalone/cpu-centos/Dockerfile 25 | $(DOCKER) build $(DOCKER_BUILD_ARG) -t caffe:cpu-centos standalone/cpu-centos 26 | 27 | cpu-ubuntu: standalone/cpu-ubuntu/Dockerfile 28 | $(DOCKER) build $(DOCKER_BUILD_ARG) -t caffe:cpu-ubuntu standalone/cpu-ubuntu 29 | 30 | gpu_standalone: standalone/gpu/Dockerfile 31 | $(DOCKER) build $(DOCKER_BUILD_ARG) -t caffe:gpu standalone/gpu 32 | 33 | 34 | docker_files: standalone_files 35 | 36 | standalone_files: standalone/cpu-centos/Dockerfile standalone/cpu-ubuntu/Dockerfile standalone/gpu/Dockerfile 37 | 38 | FROM_GPU = "nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04" 39 | FROM_CPU = "ubuntu:14.04" 40 | GPU_CMAKE_ARGS = -DUSE_CUDNN=1 41 | CPU_CMAKE_ARGS = -DCPU_ONLY=1 42 | 43 | # A make macro to select the CPU or GPU base image. 44 | define from_image 45 | $(if $(strip $(findstring gpu,$@)),$(FROM_GPU),$(FROM_CPU)) 46 | endef 47 | 48 | # A make macro to select the CPU or GPU build args. 49 | define build_args 50 | $(if $(strip $(findstring gpu,$@)),$(GPU_CMAKE_ARGS),$(CPU_CMAKE_ARGS)) 51 | endef 52 | 53 | # A make macro to construct the CPU or GPU Dockerfile from the template 54 | define create_docker_file 55 | @echo creating $@ 56 | @echo "FROM "$(from_image) > $@ 57 | @cat $^ | sed 's/$${CMAKE_ARGS}/$(build_args)/' >> $@ 58 | endef 59 | 60 | 61 | standalone/%/Dockerfile: templates/Dockerfile.template 62 | $(create_docker_file) 63 | 64 | -------------------------------------------------------------------------------- /docker/standalone/cpu-centos/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | MAINTAINER caffe-maint@googlegroups.com 3 | 4 | RUN rpm -iUvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm 5 | 6 | RUN yum install -y \ 7 | redhat-rpm-config \ 8 | tar \ 9 | findutils \ 10 | make \ 11 | gcc-c++ \ 12 | cmake \ 13 | git \ 14 | wget \ 15 | atlas-devel \ 16 | boost-devel \ 17 | gflags-devel \ 18 | glog-devel \ 19 | hdf5-devel \ 20 | leveldb-devel \ 21 | lmdb-devel \ 22 | opencv-devel \ 23 | protobuf-devel \ 24 | snappy-devel \ 25 | protobuf-compiler \ 26 | freetype-devel \ 27 | libpng-devel \ 28 | python-devel \ 29 | python-numpy \ 30 | python-pip \ 31 | python-scipy \ 32 | gcc-gfortran \ 33 | libjpeg-turbo-devel 34 | 35 | RUN yum clean all 36 | ENV CAFFE_ROOT=/opt/caffe 37 | WORKDIR $CAFFE_ROOT 38 | 39 | # FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this. 40 | ENV CLONE_TAG=master 41 | 42 | RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/intel/caffe.git . && \ 43 | for req in $(cat python/requirements.txt) pydot; do pip --no-cache-dir install $req; done && \ 44 | mkdir build && cd build && \ 45 | cmake -DCPU_ONLY=1 -DCMAKE_BUILD_TYPE=Release .. && \ 46 | make all -j"$(nproc)" 47 | 48 | ENV PYCAFFE_ROOT $CAFFE_ROOT/python 49 | ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH 50 | ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH 51 | RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig 52 | 53 | WORKDIR /workspace 54 | -------------------------------------------------------------------------------- /docker/standalone/cpu-ubuntu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER caffe-maint@googlegroups.com 3 | 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | build-essential \ 6 | cmake \ 7 | git \ 8 | wget \ 9 | libboost-all-dev \ 10 | libgflags-dev \ 11 | libgoogle-glog-dev \ 12 | libhdf5-serial-dev \ 13 | libleveldb-dev \ 14 | liblmdb-dev \ 15 | libopencv-dev \ 16 | libprotobuf-dev \ 17 | libsnappy-dev \ 18 | protobuf-compiler \ 19 | python-dev \ 20 | python-numpy \ 21 | python-pip \ 22 | python-scipy && \ 23 | rm -rf /var/lib/apt/lists/* 24 | 25 | ENV CAFFE_ROOT=/opt/caffe 26 | WORKDIR $CAFFE_ROOT 27 | 28 | # FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this. 29 | ENV CLONE_TAG=master 30 | 31 | RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/intel/caffe.git . && \ 32 | for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \ 33 | mkdir build && cd build && \ 34 | cmake -DCPU_ONLY=1 -DCMAKE_BUILD_TYPE=Release .. && \ 35 | make all -j"$(nproc)" 36 | 37 | ENV PYCAFFE_ROOT $CAFFE_ROOT/python 38 | ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH 39 | ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH 40 | RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig 41 | 42 | WORKDIR /workspace 43 | -------------------------------------------------------------------------------- /docker/standalone/gpu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 2 | MAINTAINER caffe-maint@googlegroups.com 3 | 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | build-essential \ 6 | cmake \ 7 | git \ 8 | wget \ 9 | libatlas-base-dev \ 10 | libboost-all-dev \ 11 | libgflags-dev \ 12 | libgoogle-glog-dev \ 13 | libhdf5-serial-dev \ 14 | libleveldb-dev \ 15 | liblmdb-dev \ 16 | libopencv-dev \ 17 | libprotobuf-dev \ 18 | libsnappy-dev \ 19 | protobuf-compiler \ 20 | python-dev \ 21 | python-numpy \ 22 | python-pip \ 23 | python-scipy && \ 24 | rm -rf /var/lib/apt/lists/* 25 | 26 | ENV CAFFE_ROOT=/opt/caffe 27 | WORKDIR $CAFFE_ROOT 28 | 29 | # FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this. 30 | ENV CLONE_TAG=master 31 | 32 | RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/intel/caffe.git . && \ 33 | for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \ 34 | mkdir build && cd build && \ 35 | cmake -DUSE_CUDNN=1 .. && \ 36 | make -j"$(nproc)" 37 | 38 | ENV PYCAFFE_ROOT $CAFFE_ROOT/python 39 | ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH 40 | ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH 41 | RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig 42 | 43 | WORKDIR /workspace 44 | -------------------------------------------------------------------------------- /docker/templates/Dockerfile.template: -------------------------------------------------------------------------------- 1 | MAINTAINER caffe-maint@googlegroups.com 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | build-essential \ 5 | cmake \ 6 | git \ 7 | wget \ 8 | libatlas-base-dev \ 9 | libboost-all-dev \ 10 | libgflags-dev \ 11 | libgoogle-glog-dev \ 12 | libhdf5-serial-dev \ 13 | libleveldb-dev \ 14 | liblmdb-dev \ 15 | libopencv-dev \ 16 | libprotobuf-dev \ 17 | libsnappy-dev \ 18 | protobuf-compiler \ 19 | python-dev \ 20 | python-numpy \ 21 | python-pip \ 22 | python-scipy && \ 23 | rm -rf /var/lib/apt/lists/* 24 | 25 | ENV CAFFE_ROOT=/opt/caffe 26 | WORKDIR $CAFFE_ROOT 27 | 28 | # FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this. 29 | ENV CLONE_TAG=master 30 | 31 | RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/BVLC/caffe.git . && \ 32 | for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \ 33 | mkdir build && cd build && \ 34 | cmake ${CMAKE_ARGS} .. && \ 35 | make -j"$(nproc)" 36 | 37 | ENV PYCAFFE_ROOT $CAFFE_ROOT/python 38 | ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH 39 | ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH 40 | RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig 41 | 42 | WORKDIR /workspace 43 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | caffe.berkeleyvision.org 2 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Caffe Documentation 2 | 3 | To generate the documentation, run `$CAFFE_ROOT/scripts/build_docs.sh`. 4 | 5 | To push your changes to the documentation to the gh-pages branch of your or the BVLC repo, run `$CAFFE_ROOT/scripts/deploy_docs.sh `. 6 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | defaults: 2 | - 3 | scope: 4 | path: "" # an empty string here means all files in the project 5 | values: 6 | layout: "default" 7 | 8 | -------------------------------------------------------------------------------- /docs/images/GitHub-Mark-64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/images/GitHub-Mark-64px.png -------------------------------------------------------------------------------- /docs/images/caffeine-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/images/caffeine-icon.png -------------------------------------------------------------------------------- /docs/install_apt.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation: Ubuntu 3 | --- 4 | 5 | # Ubuntu Installation 6 | 7 | **General dependencies** 8 | 9 | sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler 10 | sudo apt-get install --no-install-recommends libboost-all-dev 11 | 12 | **CUDA**: Install via the NVIDIA package instead of `apt-get` to be certain of the library and driver versions. 13 | Install the library and latest driver separately; the driver bundled with the library is usually out-of-date. 14 | This can be skipped for CPU-only installation. 15 | 16 | **BLAS**: install ATLAS by `sudo apt-get install libatlas-base-dev` or install OpenBLAS or MKL for better CPU performance. 17 | 18 | **Python** (optional): if you use the default Python you will need to `sudo apt-get install` the `python-dev` package to have the Python headers for building the pycaffe interface. 19 | 20 | **Remaining dependencies, 14.04** 21 | 22 | Everything is packaged in 14.04. 23 | 24 | sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev 25 | 26 | **Remaining dependencies, 12.04** 27 | 28 | These dependencies need manual installation in 12.04. 29 | 30 | # glog 31 | wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz 32 | tar zxvf glog-0.3.3.tar.gz 33 | cd glog-0.3.3 34 | ./configure 35 | make && make install 36 | # gflags 37 | wget https://github.com/schuhschuh/gflags/archive/master.zip 38 | unzip master.zip 39 | cd gflags-master 40 | mkdir build && cd build 41 | export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1 42 | make && make install 43 | # lmdb 44 | git clone https://github.com/LMDB/lmdb 45 | cd lmdb/libraries/liblmdb 46 | make && make install 47 | 48 | Note that glog does not compile with the most recent gflags version (2.1), so before that is resolved you will need to build with glog first. 49 | 50 | Continue with [compilation](installation.html#compilation). 51 | -------------------------------------------------------------------------------- /docs/install_yum.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation: RHEL / Fedora / CentOS 3 | --- 4 | 5 | # RHEL / Fedora / CentOS Installation 6 | 7 | **General dependencies** 8 | 9 | sudo yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel 10 | 11 | **Remaining dependencies, recent OS** 12 | 13 | sudo yum install gflags-devel glog-devel lmdb-devel 14 | 15 | **Remaining dependencies, if not found** 16 | 17 | # glog 18 | wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz 19 | tar zxvf glog-0.3.3.tar.gz 20 | cd glog-0.3.3 21 | ./configure 22 | make && make install 23 | # gflags 24 | wget https://github.com/schuhschuh/gflags/archive/master.zip 25 | unzip master.zip 26 | cd gflags-master 27 | mkdir build && cd build 28 | export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1 29 | make && make install 30 | # lmdb 31 | git clone https://github.com/LMDB/lmdb 32 | cd lmdb/libraries/liblmdb 33 | make && make install 34 | 35 | Note that glog does not compile with the most recent gflags version (2.1), so before that is resolved you will need to build with glog first. 36 | 37 | **CUDA**: Install via the NVIDIA package instead of `yum` to be certain of the library and driver versions. 38 | Install the library and latest driver separately; the driver bundled with the library is usually out-of-date. 39 | + CentOS/RHEL/Fedora: 40 | 41 | **BLAS**: install ATLAS by `sudo yum install atlas-devel` or install OpenBLAS or MKL for better CPU performance. For the Makefile build, uncomment and set `BLAS_LIB` accordingly as ATLAS is usually installed under `/usr/lib[64]/atlas`). 42 | 43 | **Python** (optional): if you use the default Python you will need to `sudo yum install` the `python-devel` package to have the Python headers for building the pycaffe wrapper. 44 | 45 | Continue with [compilation](installation.html#compilation). 46 | -------------------------------------------------------------------------------- /docs/stylesheets/reset.css: -------------------------------------------------------------------------------- 1 | /* MeyerWeb Reset */ 2 | 3 | html, body, div, span, applet, object, iframe, 4 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 5 | a, abbr, acronym, address, big, cite, code, 6 | del, dfn, em, img, ins, kbd, q, s, samp, 7 | small, strike, strong, sub, sup, tt, var, 8 | b, u, i, center, 9 | dl, dt, dd, ol, ul, li, 10 | fieldset, form, label, legend, 11 | table, caption, tbody, tfoot, thead, tr, th, td, 12 | article, aside, canvas, details, embed, 13 | figure, figcaption, footer, header, hgroup, 14 | menu, nav, output, ruby, section, summary, 15 | time, mark, audio, video { 16 | margin: 0; 17 | padding: 0; 18 | border: 0; 19 | font: inherit; 20 | vertical-align: baseline; 21 | } 22 | -------------------------------------------------------------------------------- /docs/tutorial/convolution.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Convolution 3 | --- 4 | # Caffeinated Convolution 5 | 6 | The Caffe strategy for convolution is to reduce the problem to matrix-matrix multiplication. 7 | This linear algebra computation is highly-tuned in BLAS libraries and efficiently computed on GPU devices. 8 | 9 | For more details read Yangqing's [Convolution in Caffe: a memo](https://github.com/Yangqing/caffe/wiki/Convolution-in-Caffe:-a-memo). 10 | 11 | As it turns out, this same reduction was independently explored in the context of conv. nets by 12 | 13 | > K. Chellapilla, S. Puri, P. Simard, et al. High performance convolutional neural networks for document processing. In Tenth International Workshop on Frontiers in Handwriting Recognition, 2006. 14 | -------------------------------------------------------------------------------- /docs/tutorial/fig/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/tutorial/fig/.gitignore -------------------------------------------------------------------------------- /docs/tutorial/fig/backward.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/tutorial/fig/backward.jpg -------------------------------------------------------------------------------- /docs/tutorial/fig/forward.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/tutorial/fig/forward.jpg -------------------------------------------------------------------------------- /docs/tutorial/fig/forward_backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/tutorial/fig/forward_backward.png -------------------------------------------------------------------------------- /docs/tutorial/fig/layer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/tutorial/fig/layer.jpg -------------------------------------------------------------------------------- /docs/tutorial/fig/logreg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/docs/tutorial/fig/logreg.jpg -------------------------------------------------------------------------------- /examples/C3D_train/1.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/C3D_train/1.avi -------------------------------------------------------------------------------- /examples/C3D_train/c3d_solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "c3d.prototxt" 2 | #test_iter: 100 3 | #test_interval: 500 4 | base_lr: 0.01 5 | momentum: 0.9 6 | type:"Adam" 7 | weight_decay: 0.0005 8 | lr_policy: "inv" 9 | gamma: 0.0001 10 | power: 0.75 11 | display: 100 12 | max_iter: 20000 13 | snapshot: 5000 14 | snapshot_prefix: "focnet" 15 | solver_mode: CPU 16 | -------------------------------------------------------------------------------- /examples/C3D_train/run_C3d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TOOLS=../../build/tools 4 | 5 | export HDF5_DISABLE_VERSION_CHECK=1 6 | export PYTHONPATH=. 7 | 8 | GLOG_logtostderr=1 $TOOLS/caffe train -solver c3d_solver.prototxt 9 | echo "Done." 10 | -------------------------------------------------------------------------------- /examples/C3D_train/whole_frame.py: -------------------------------------------------------------------------------- 1 | import h5py 2 | import numpy as np 3 | import skvideo.datasets 4 | import skvideo.io 5 | 6 | videodata = skvideo.io.vread('1.avi') 7 | count = 0 8 | data = videodata 9 | data=data.transpose(3,0,1,2) # To chanelxdepthxhxw 10 | data=data[None,:,:,:] 11 | print(videodata) 12 | 13 | with h5py.File('data.h5','w') as f: 14 | f['data'] = data 15 | f['label'] = np.ones((1,1), dtype=np.float32) 16 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE examples_srcs "${PROJECT_SOURCE_DIR}/examples/*.cpp") 2 | 3 | foreach(source_file ${examples_srcs}) 4 | # get file name 5 | get_filename_component(name ${source_file} NAME_WE) 6 | 7 | # get folder name 8 | get_filename_component(path ${source_file} PATH) 9 | get_filename_component(folder ${path} NAME_WE) 10 | 11 | add_executable(${name} ${source_file}) 12 | target_link_libraries(${name} ${Caffe_LINK}) 13 | caffe_default_properties(${name}) 14 | 15 | # set back RUNTIME_OUTPUT_DIRECTORY 16 | set_target_properties(${name} PROPERTIES 17 | RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/examples/${folder}") 18 | 19 | caffe_set_solution_folder(${name} examples) 20 | 21 | # install 22 | install(TARGETS ${name} DESTINATION bin) 23 | 24 | if(UNIX OR APPLE) 25 | # Funny command to make tutorials work 26 | # TODO: remove in future as soon as naming is standartaized everywhere 27 | set(__outname ${PROJECT_BINARY_DIR}/examples/${folder}/${name}${Caffe_POSTFIX}) 28 | add_custom_command(TARGET ${name} POST_BUILD 29 | COMMAND ln -sf "${__outname}" "${__outname}.bin") 30 | endif() 31 | endforeach() 32 | -------------------------------------------------------------------------------- /examples/LRCN_activity_recognition/README.txt: -------------------------------------------------------------------------------- 1 | This code should help you reimplement the experiments in: 2 | 3 | Donahue, J., Hendricks, L. A., Guadarrama, S., Rohrbach, M., Venugopalan, S., Saenko, K., & Darrell, T. (2014). Long-term recurrent convolutional networks for visual recognition and description. arXiv preprint arXiv:1411.4389. 4 | Chicago 5 | 6 | Please see http://www.eecs.berkeley.edu/~lisa_anne/LRCN_video for detailed instructions on how to reimplement experiments and download pre-trained models. 7 | 8 | -------------------------------------------------------------------------------- /examples/LRCN_activity_recognition/extract_frames.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | EXPECTED_ARGS=2 4 | E_BADARGS=65 5 | 6 | if [ $# -lt $EXPECTED_ARGS ] 7 | then 8 | echo "Usage: `basename $0` video frames/sec [size=256]" 9 | exit $E_BADARGS 10 | fi 11 | 12 | NAME=${1%.*} 13 | FRAMES=$2 14 | BNAME=`basename $NAME` 15 | echo $BNAME 16 | mkdir -m 755 $BNAME 17 | 18 | ffmpeg -i $1 -r $FRAMES $BNAME/$BNAME.%4d.jpg 19 | -------------------------------------------------------------------------------- /examples/LRCN_activity_recognition/lstm_solver_RGB.prototxt: -------------------------------------------------------------------------------- 1 | net: "train_test_lstm_RGB.prototxt" 2 | test_iter: 100 3 | test_state: { stage: 'test-on-test' } 4 | test_interval: 100 5 | base_lr: 0.001 6 | lr_policy: "step" 7 | gamma: 0.1 8 | stepsize: 10000 9 | display: 20 10 | max_iter: 30000 11 | momentum: 0.9 12 | weight_decay: 0.005 13 | snapshot: 5000 14 | snapshot_prefix: "snapshots_lstm_RGB" 15 | solver_mode: CPU 16 | device_id: 0 17 | random_seed: 1701 18 | average_loss: 1000 19 | clip_gradients: 5 20 | -------------------------------------------------------------------------------- /examples/LRCN_activity_recognition/run_lstm_RGB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TOOLS=../../build/tools 4 | 5 | export HDF5_DISABLE_VERSION_CHECK=1 6 | export PYTHONPATH=. 7 | 8 | GLOG_logtostderr=1 $TOOLS/caffe train -solver lstm_solver_RGB.prototxt -weights single_frame_all_layers_hyb_RGB_iter_5000.caffemodel 9 | echo "Done." 10 | -------------------------------------------------------------------------------- /examples/LRCN_activity_recognition/run_singleFrame_RGB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TOOLS=../../build/tools 3 | 4 | GLOG_logtostderr=1 $TOOLS/caffe train -solver singleFrame_solver_RGB.prototxt -weights caffe_imagenet_hyb2_wr_rc_solver_sqrt_iter_310000 5 | echo 'Done.' 6 | -------------------------------------------------------------------------------- /examples/LRCN_activity_recognition/singleFrame_solver_RGB.prototxt: -------------------------------------------------------------------------------- 1 | net: "train_test_singleFrame_RGB.prototxt" 2 | test_iter: 75 3 | test_state: { stage: 'test-on-test' } 4 | test_interval: 100 5 | base_lr: 0.001 6 | lr_policy: "step" 7 | gamma: 0.1 8 | stepsize: 3000 9 | display: 20 10 | max_iter: 5000 11 | momentum: 0.9 12 | weight_decay: 0.005 13 | snapshot: 5000 14 | snapshot_prefix: "snapshots_singleFrame_RGB" 15 | solver_mode: GPU 16 | device_id: 0 17 | random_seed: 1701 18 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_full_sigmoid_solver.prototxt: -------------------------------------------------------------------------------- 1 | # reduce learning rate after 120 epochs (60000 iters) by factor 0f 10 2 | # then another factor of 10 after 10 more epochs (5000 iters) 3 | 4 | # The train/test net protocol buffer definition 5 | net: "examples/cifar10/cifar10_full_sigmoid_train_test.prototxt" 6 | # test_iter specifies how many forward passes the test should carry out. 7 | # In the case of CIFAR10, we have test batch size 100 and 100 test iterations, 8 | # covering the full 10,000 testing images. 9 | test_iter: 10 10 | # Carry out testing every 1000 training iterations. 11 | test_interval: 1000 12 | # The base learning rate, momentum and the weight decay of the network. 13 | base_lr: 0.001 14 | momentum: 0.9 15 | #weight_decay: 0.004 16 | # The learning rate policy 17 | lr_policy: "step" 18 | gamma: 1 19 | stepsize: 5000 20 | # Display every 200 iterations 21 | display: 100 22 | # The maximum number of iterations 23 | max_iter: 60000 24 | # snapshot intermediate results 25 | snapshot: 10000 26 | snapshot_prefix: "examples/cifar10_full_sigmoid" 27 | # solver mode: CPU or GPU 28 | solver_mode: CPU 29 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_full_sigmoid_solver_bn.prototxt: -------------------------------------------------------------------------------- 1 | # reduce learning rate after 120 epochs (60000 iters) by factor 0f 10 2 | # then another factor of 10 after 10 more epochs (5000 iters) 3 | 4 | # The train/test net protocol buffer definition 5 | net: "examples/cifar10/cifar10_full_sigmoid_train_test_bn.prototxt" 6 | # test_iter specifies how many forward passes the test should carry out. 7 | # In the case of CIFAR10, we have test batch size 100 and 100 test iterations, 8 | # covering the full 10,000 testing images. 9 | test_iter: 10 10 | # Carry out testing every 1000 training iterations. 11 | test_interval: 1000 12 | # The base learning rate, momentum and the weight decay of the network. 13 | base_lr: 0.001 14 | momentum: 0.9 15 | #weight_decay: 0.004 16 | # The learning rate policy 17 | lr_policy: "step" 18 | gamma: 1 19 | stepsize: 5000 20 | # Display every 200 iterations 21 | display: 100 22 | # The maximum number of iterations 23 | max_iter: 60000 24 | # snapshot intermediate results 25 | snapshot: 10000 26 | snapshot_prefix: "examples/cifar10_full_sigmoid_bn" 27 | # solver mode: CPU or GPU 28 | solver_mode: CPU 29 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_full_solver.prototxt: -------------------------------------------------------------------------------- 1 | # reduce learning rate after 120 epochs (60000 iters) by factor 0f 10 2 | # then another factor of 10 after 10 more epochs (5000 iters) 3 | 4 | # The train/test net protocol buffer definition 5 | net: "examples/cifar10/cifar10_full_train_test.prototxt" 6 | # test_iter specifies how many forward passes the test should carry out. 7 | # In the case of CIFAR10, we have test batch size 100 and 100 test iterations, 8 | # covering the full 10,000 testing images. 9 | test_iter: 100 10 | # Carry out testing every 1000 training iterations. 11 | test_interval: 1000 12 | # The base learning rate, momentum and the weight decay of the network. 13 | base_lr: 0.001 14 | momentum: 0.9 15 | weight_decay: 0.004 16 | # The learning rate policy 17 | lr_policy: "fixed" 18 | # Display every 200 iterations 19 | display: 10 20 | # The maximum number of iterations 21 | max_iter: 60000 22 | # snapshot intermediate results 23 | snapshot: 10000 24 | snapshot_format: HDF5 25 | snapshot_prefix: "examples/cifar10/cifar10_full" 26 | # solver mode: CPU or GPU 27 | solver_mode: CPU 28 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_full_solver_lr1.prototxt: -------------------------------------------------------------------------------- 1 | # reduce learning rate after 120 epochs (60000 iters) by factor 0f 10 2 | # then another factor of 10 after 10 more epochs (5000 iters) 3 | 4 | # The train/test net protocol buffer definition 5 | net: "examples/cifar10/cifar10_full_train_test.prototxt" 6 | # test_iter specifies how many forward passes the test should carry out. 7 | # In the case of CIFAR10, we have test batch size 100 and 100 test iterations, 8 | # covering the full 10,000 testing images. 9 | test_iter: 100 10 | # Carry out testing every 1000 training iterations. 11 | test_interval: 1000 12 | # The base learning rate, momentum and the weight decay of the network. 13 | base_lr: 0.0001 14 | momentum: 0.9 15 | weight_decay: 0.004 16 | # The learning rate policy 17 | lr_policy: "fixed" 18 | # Display every 200 iterations 19 | display: 200 20 | # The maximum number of iterations 21 | max_iter: 65000 22 | # snapshot intermediate results 23 | snapshot: 5000 24 | snapshot_format: HDF5 25 | snapshot_prefix: "examples/cifar10/cifar10_full" 26 | # solver mode: CPU or GPU 27 | solver_mode: CPU 28 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_full_solver_lr2.prototxt: -------------------------------------------------------------------------------- 1 | # reduce learning rate after 120 epochs (60000 iters) by factor 0f 10 2 | # then another factor of 10 after 10 more epochs (5000 iters) 3 | 4 | # The train/test net protocol buffer definition 5 | net: "examples/cifar10/cifar10_full_train_test.prototxt" 6 | # test_iter specifies how many forward passes the test should carry out. 7 | # In the case of CIFAR10, we have test batch size 100 and 100 test iterations, 8 | # covering the full 10,000 testing images. 9 | test_iter: 100 10 | # Carry out testing every 1000 training iterations. 11 | test_interval: 1000 12 | # The base learning rate, momentum and the weight decay of the network. 13 | base_lr: 0.00001 14 | momentum: 0.9 15 | weight_decay: 0.004 16 | # The learning rate policy 17 | lr_policy: "fixed" 18 | # Display every 200 iterations 19 | display: 200 20 | # The maximum number of iterations 21 | max_iter: 70000 22 | # snapshot intermediate results 23 | snapshot: 5000 24 | snapshot_format: HDF5 25 | snapshot_prefix: "examples/cifar10/cifar10_full" 26 | # solver mode: CPU or GPU 27 | solver_mode: CPU 28 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_quick_solver.prototxt: -------------------------------------------------------------------------------- 1 | # reduce the learning rate after 8 epochs (4000 iters) by a factor of 10 2 | 3 | # The train/test net protocol buffer definition 4 | net: "examples/cifar10/cifar10_quick_train_test.prototxt" 5 | # test_iter specifies how many forward passes the test should carry out. 6 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 7 | # covering the full 10,000 testing images. 8 | test_iter: 100 9 | # Carry out testing every 500 training iterations. 10 | test_interval: 500 11 | # The base learning rate, momentum and the weight decay of the network. 12 | base_lr: 0.001 13 | momentum: 0.9 14 | weight_decay: 0.004 15 | # The learning rate policy 16 | lr_policy: "fixed" 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 4000 21 | # snapshot intermediate results 22 | snapshot: 4000 23 | snapshot_format: HDF5 24 | snapshot_prefix: "examples/cifar10/cifar10_quick" 25 | # solver mode: CPU or GPU 26 | solver_mode: CPU 27 | -------------------------------------------------------------------------------- /examples/cifar10/cifar10_quick_solver_lr1.prototxt: -------------------------------------------------------------------------------- 1 | # reduce the learning rate after 8 epochs (4000 iters) by a factor of 10 2 | 3 | # The train/test net protocol buffer definition 4 | net: "examples/cifar10/cifar10_quick_train_test.prototxt" 5 | # test_iter specifies how many forward passes the test should carry out. 6 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 7 | # covering the full 10,000 testing images. 8 | test_iter: 100 9 | # Carry out testing every 500 training iterations. 10 | test_interval: 500 11 | # The base learning rate, momentum and the weight decay of the network. 12 | base_lr: 0.0001 13 | momentum: 0.9 14 | weight_decay: 0.004 15 | # The learning rate policy 16 | lr_policy: "fixed" 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 5000 21 | # snapshot intermediate results 22 | snapshot: 5000 23 | snapshot_format: HDF5 24 | snapshot_prefix: "examples/cifar10/cifar10_quick" 25 | # solver mode: CPU or GPU 26 | solver_mode: CPU 27 | -------------------------------------------------------------------------------- /examples/finetune_flickr_style/flickr_style.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/finetune_flickr_style/flickr_style.csv.gz -------------------------------------------------------------------------------- /examples/finetune_flickr_style/style_names.txt: -------------------------------------------------------------------------------- 1 | Detailed 2 | Pastel 3 | Melancholy 4 | Noir 5 | HDR 6 | Vintage 7 | Long Exposure 8 | Horror 9 | Sunny 10 | Bright 11 | Hazy 12 | Bokeh 13 | Serene 14 | Texture 15 | Ethereal 16 | Macro 17 | Depth of Field 18 | Geometric Composition 19 | Minimal 20 | Romantic 21 | -------------------------------------------------------------------------------- /examples/finetune_pascal_detection/pascal_finetune_solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "examples/finetune_pascal_detection/pascal_finetune_trainval_test.prototxt" 2 | test_iter: 100 3 | test_interval: 1000 4 | base_lr: 0.001 5 | lr_policy: "step" 6 | gamma: 0.1 7 | stepsize: 20000 8 | display: 20 9 | max_iter: 100000 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 10000 13 | snapshot_prefix: "examples/finetune_pascal_detection/pascal_det_finetune" 14 | -------------------------------------------------------------------------------- /examples/hdf5_classification/nonlinear_auto_test.prototxt: -------------------------------------------------------------------------------- 1 | layer { 2 | name: "data" 3 | type: "HDF5Data" 4 | top: "data" 5 | top: "label" 6 | hdf5_data_param { 7 | source: "examples/hdf5_classification/data/test.txt" 8 | batch_size: 10 9 | } 10 | } 11 | layer { 12 | name: "ip1" 13 | type: "InnerProduct" 14 | bottom: "data" 15 | top: "ip1" 16 | inner_product_param { 17 | num_output: 40 18 | weight_filler { 19 | type: "xavier" 20 | } 21 | } 22 | } 23 | layer { 24 | name: "relu1" 25 | type: "ReLU" 26 | bottom: "ip1" 27 | top: "ip1" 28 | } 29 | layer { 30 | name: "ip2" 31 | type: "InnerProduct" 32 | bottom: "ip1" 33 | top: "ip2" 34 | inner_product_param { 35 | num_output: 2 36 | weight_filler { 37 | type: "xavier" 38 | } 39 | } 40 | } 41 | layer { 42 | name: "accuracy" 43 | type: "Accuracy" 44 | bottom: "ip2" 45 | bottom: "label" 46 | top: "accuracy" 47 | } 48 | layer { 49 | name: "loss" 50 | type: "SoftmaxWithLoss" 51 | bottom: "ip2" 52 | bottom: "label" 53 | top: "loss" 54 | } 55 | -------------------------------------------------------------------------------- /examples/hdf5_classification/nonlinear_auto_train.prototxt: -------------------------------------------------------------------------------- 1 | layer { 2 | name: "data" 3 | type: "HDF5Data" 4 | top: "data" 5 | top: "label" 6 | hdf5_data_param { 7 | source: "examples/hdf5_classification/data/train.txt" 8 | batch_size: 10 9 | } 10 | } 11 | layer { 12 | name: "ip1" 13 | type: "InnerProduct" 14 | bottom: "data" 15 | top: "ip1" 16 | inner_product_param { 17 | num_output: 40 18 | weight_filler { 19 | type: "xavier" 20 | } 21 | } 22 | } 23 | layer { 24 | name: "relu1" 25 | type: "ReLU" 26 | bottom: "ip1" 27 | top: "ip1" 28 | } 29 | layer { 30 | name: "ip2" 31 | type: "InnerProduct" 32 | bottom: "ip1" 33 | top: "ip2" 34 | inner_product_param { 35 | num_output: 2 36 | weight_filler { 37 | type: "xavier" 38 | } 39 | } 40 | } 41 | layer { 42 | name: "accuracy" 43 | type: "Accuracy" 44 | bottom: "ip2" 45 | bottom: "label" 46 | top: "accuracy" 47 | } 48 | layer { 49 | name: "loss" 50 | type: "SoftmaxWithLoss" 51 | bottom: "ip2" 52 | bottom: "label" 53 | top: "loss" 54 | } 55 | -------------------------------------------------------------------------------- /examples/hdf5_classification/nonlinear_train_val.prototxt: -------------------------------------------------------------------------------- 1 | name: "LogisticRegressionNet" 2 | layer { 3 | name: "data" 4 | type: "HDF5Data" 5 | top: "data" 6 | top: "label" 7 | include { 8 | phase: TRAIN 9 | } 10 | hdf5_data_param { 11 | source: "examples/hdf5_classification/data/train.txt" 12 | batch_size: 10 13 | } 14 | } 15 | layer { 16 | name: "data" 17 | type: "HDF5Data" 18 | top: "data" 19 | top: "label" 20 | include { 21 | phase: TEST 22 | } 23 | hdf5_data_param { 24 | source: "examples/hdf5_classification/data/test.txt" 25 | batch_size: 10 26 | } 27 | } 28 | layer { 29 | name: "fc1" 30 | type: "InnerProduct" 31 | bottom: "data" 32 | top: "fc1" 33 | param { 34 | lr_mult: 1 35 | decay_mult: 1 36 | } 37 | param { 38 | lr_mult: 2 39 | decay_mult: 0 40 | } 41 | inner_product_param { 42 | num_output: 40 43 | weight_filler { 44 | type: "xavier" 45 | } 46 | bias_filler { 47 | type: "constant" 48 | value: 0 49 | } 50 | } 51 | } 52 | layer { 53 | name: "relu1" 54 | type: "ReLU" 55 | bottom: "fc1" 56 | top: "fc1" 57 | } 58 | layer { 59 | name: "fc2" 60 | type: "InnerProduct" 61 | bottom: "fc1" 62 | top: "fc2" 63 | param { 64 | lr_mult: 1 65 | decay_mult: 1 66 | } 67 | param { 68 | lr_mult: 2 69 | decay_mult: 0 70 | } 71 | inner_product_param { 72 | num_output: 2 73 | weight_filler { 74 | type: "xavier" 75 | } 76 | bias_filler { 77 | type: "constant" 78 | value: 0 79 | } 80 | } 81 | } 82 | layer { 83 | name: "loss" 84 | type: "SoftmaxWithLoss" 85 | bottom: "fc2" 86 | bottom: "label" 87 | top: "loss" 88 | } 89 | layer { 90 | name: "accuracy" 91 | type: "Accuracy" 92 | bottom: "fc2" 93 | bottom: "label" 94 | top: "accuracy" 95 | include { 96 | phase: TEST 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /examples/hdf5_classification/train_val.prototxt: -------------------------------------------------------------------------------- 1 | name: "LogisticRegressionNet" 2 | layer { 3 | name: "data" 4 | type: "HDF5Data" 5 | top: "data" 6 | top: "label" 7 | include { 8 | phase: TRAIN 9 | } 10 | hdf5_data_param { 11 | source: "examples/hdf5_classification/data/train.txt" 12 | batch_size: 10 13 | } 14 | } 15 | layer { 16 | name: "data" 17 | type: "HDF5Data" 18 | top: "data" 19 | top: "label" 20 | include { 21 | phase: TEST 22 | } 23 | hdf5_data_param { 24 | source: "examples/hdf5_classification/data/test.txt" 25 | batch_size: 10 26 | } 27 | } 28 | layer { 29 | name: "fc1" 30 | type: "InnerProduct" 31 | bottom: "data" 32 | top: "fc1" 33 | param { 34 | lr_mult: 1 35 | decay_mult: 1 36 | } 37 | param { 38 | lr_mult: 2 39 | decay_mult: 0 40 | } 41 | inner_product_param { 42 | num_output: 2 43 | weight_filler { 44 | type: "xavier" 45 | } 46 | bias_filler { 47 | type: "constant" 48 | value: 0 49 | } 50 | } 51 | } 52 | layer { 53 | name: "loss" 54 | type: "SoftmaxWithLoss" 55 | bottom: "fc1" 56 | bottom: "label" 57 | top: "loss" 58 | } 59 | layer { 60 | name: "accuracy" 61 | type: "Accuracy" 62 | bottom: "fc1" 63 | bottom: "label" 64 | top: "accuracy" 65 | include { 66 | phase: TEST 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /examples/imagenet/train_caffenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # 3 | # All modification made by Intel Corporation: © 2016 Intel Corporation 4 | # 5 | # All contributions by the University of California: 6 | # Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 7 | # All rights reserved. 8 | # 9 | # All other contributions: 10 | # Copyright (c) 2014, 2015, the respective contributors 11 | # All rights reserved. 12 | # For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 13 | # 14 | # 15 | # Redistribution and use in source and binary forms, with or without 16 | # modification, are permitted provided that the following conditions are met: 17 | # 18 | # * Redistributions of source code must retain the above copyright notice, 19 | # this list of conditions and the following disclaimer. 20 | # * Redistributions in binary form must reproduce the above copyright 21 | # notice, this list of conditions and the following disclaimer in the 22 | # documentation and/or other materials provided with the distribution. 23 | # * Neither the name of Intel Corporation nor the names of its contributors 24 | # may be used to endorse or promote products derived from this software 25 | # without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 31 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | # 38 | set -e 39 | 40 | ./build/tools/caffe train \ 41 | --solver=models/bvlc_reference_caffenet/solver.prototxt $@ 42 | -------------------------------------------------------------------------------- /examples/images/cat gray.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/images/cat gray.jpg -------------------------------------------------------------------------------- /examples/images/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/images/cat.jpg -------------------------------------------------------------------------------- /examples/images/cat_gray.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/images/cat_gray.jpg -------------------------------------------------------------------------------- /examples/images/fish-bike.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/images/fish-bike.jpg -------------------------------------------------------------------------------- /examples/mnist/lenet_adadelta_solver.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 500 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 1.0 11 | lr_policy: "fixed" 12 | momentum: 0.95 13 | weight_decay: 0.0005 14 | # Display every 100 iterations 15 | display: 100 16 | # The maximum number of iterations 17 | max_iter: 10000 18 | # snapshot intermediate results 19 | snapshot: 5000 20 | snapshot_prefix: "examples/mnist/lenet_adadelta" 21 | # solver mode: CPU or GPU 22 | solver_mode: GPU 23 | type: "AdaDelta" 24 | delta: 1e-6 25 | -------------------------------------------------------------------------------- /examples/mnist/lenet_auto_solver.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | train_net: "mnist/lenet_auto_train.prototxt" 3 | test_net: "mnist/lenet_auto_test.prototxt" 4 | # test_iter specifies how many forward passes the test should carry out. 5 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 6 | # covering the full 10,000 testing images. 7 | test_iter: 100 8 | # Carry out testing every 500 training iterations. 9 | test_interval: 500 10 | # The base learning rate, momentum and the weight decay of the network. 11 | base_lr: 0.01 12 | momentum: 0.9 13 | weight_decay: 0.0005 14 | # The learning rate policy 15 | lr_policy: "inv" 16 | gamma: 0.0001 17 | power: 0.75 18 | # Display every 100 iterations 19 | display: 100 20 | # The maximum number of iterations 21 | max_iter: 10000 22 | # snapshot intermediate results 23 | snapshot: 5000 24 | snapshot_prefix: "mnist/lenet" 25 | -------------------------------------------------------------------------------- /examples/mnist/lenet_multistep_solver.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 500 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "multistep" 15 | gamma: 0.9 16 | stepvalue: 5000 17 | stepvalue: 7000 18 | stepvalue: 8000 19 | stepvalue: 9000 20 | stepvalue: 9500 21 | # Display every 100 iterations 22 | display: 100 23 | # The maximum number of iterations 24 | max_iter: 10000 25 | # snapshot intermediate results 26 | snapshot: 5000 27 | snapshot_prefix: "examples/mnist/lenet_multistep" 28 | # solver mode: CPU or GPU 29 | solver_mode: GPU 30 | -------------------------------------------------------------------------------- /examples/mnist/lenet_solver.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 500 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 10000 21 | # snapshot intermediate results 22 | snapshot: 5000 23 | snapshot_prefix: "examples/mnist/lenet" 24 | # solver mode: CPU or GPU 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /examples/mnist/lenet_solver_adam.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | # this follows "ADAM: A METHOD FOR STOCHASTIC OPTIMIZATION" 3 | net: "examples/mnist/lenet_train_test.prototxt" 4 | # test_iter specifies how many forward passes the test should carry out. 5 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 6 | # covering the full 10,000 testing images. 7 | test_iter: 100 8 | # Carry out testing every 500 training iterations. 9 | test_interval: 500 10 | # All parameters are from the cited paper above 11 | base_lr: 0.001 12 | momentum: 0.9 13 | momentum2: 0.999 14 | # since Adam dynamically changes the learning rate, we set the base learning 15 | # rate to a fixed value 16 | lr_policy: "fixed" 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 10000 21 | # snapshot intermediate results 22 | snapshot: 5000 23 | snapshot_prefix: "examples/mnist/lenet" 24 | # solver mode: CPU or GPU 25 | type: "Adam" 26 | solver_mode: GPU 27 | -------------------------------------------------------------------------------- /examples/mnist/lenet_solver_mlsl.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test_mlsl.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 10000 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 50 21 | # snapshot intermediate results 22 | snapshot: 10000 23 | snapshot_prefix: "examples/mnist/lenet_mlsl" 24 | # solver mode: CPU or GPU 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /examples/mnist/lenet_solver_mlsl2.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test_mlsl2.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 500 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 10 19 | # The maximum number of iterations 20 | max_iter: 500 21 | # snapshot intermediate results 22 | snapshot: 5000 23 | snapshot_prefix: "examples/mnist/lenet" 24 | # solver mode: CPU or GPU 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /examples/mnist/lenet_solver_mlsl3.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test_mlsl3.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 10000 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 2 19 | # The maximum number of iterations 20 | max_iter: 10 21 | # snapshot intermediate results 22 | snapshot: 10000 23 | snapshot_prefix: "examples/mnist/lenet_mlsl" 24 | # solver mode: CPU or GPU 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /examples/mnist/lenet_solver_rmsprop.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/mnist/lenet_train_test.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 500 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.0 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 10000 21 | # snapshot intermediate results 22 | snapshot: 5000 23 | snapshot_prefix: "examples/mnist/lenet_rmsprop" 24 | # solver mode: CPU or GPU 25 | solver_mode: GPU 26 | type: "RMSProp" 27 | rms_decay: 0.98 28 | -------------------------------------------------------------------------------- /examples/mnist/mnist_autoencoder_solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "examples/mnist/mnist_autoencoder.prototxt" 2 | test_state: { stage: 'test-on-train' } 3 | test_iter: 500 4 | test_state: { stage: 'test-on-test' } 5 | test_iter: 100 6 | test_interval: 500 7 | test_compute_loss: true 8 | base_lr: 0.01 9 | lr_policy: "step" 10 | gamma: 0.1 11 | stepsize: 10000 12 | display: 100 13 | max_iter: 65000 14 | weight_decay: 0.0005 15 | snapshot: 10000 16 | snapshot_prefix: "examples/mnist/mnist_autoencoder" 17 | momentum: 0.9 18 | # solver mode: CPU or GPU 19 | solver_mode: GPU 20 | -------------------------------------------------------------------------------- /examples/mnist/mnist_autoencoder_solver_adadelta.prototxt: -------------------------------------------------------------------------------- 1 | net: "examples/mnist/mnist_autoencoder.prototxt" 2 | test_state: { stage: 'test-on-train' } 3 | test_iter: 500 4 | test_state: { stage: 'test-on-test' } 5 | test_iter: 100 6 | test_interval: 500 7 | test_compute_loss: true 8 | base_lr: 1.0 9 | lr_policy: "fixed" 10 | momentum: 0.95 11 | delta: 1e-8 12 | display: 100 13 | max_iter: 65000 14 | weight_decay: 0.0005 15 | snapshot: 10000 16 | snapshot_prefix: "examples/mnist/mnist_autoencoder_adadelta_train" 17 | # solver mode: CPU or GPU 18 | solver_mode: GPU 19 | type: "AdaDelta" 20 | -------------------------------------------------------------------------------- /examples/mnist/mnist_autoencoder_solver_adagrad.prototxt: -------------------------------------------------------------------------------- 1 | net: "examples/mnist/mnist_autoencoder.prototxt" 2 | test_state: { stage: 'test-on-train' } 3 | test_iter: 500 4 | test_state: { stage: 'test-on-test' } 5 | test_iter: 100 6 | test_interval: 500 7 | test_compute_loss: true 8 | base_lr: 0.01 9 | lr_policy: "fixed" 10 | display: 100 11 | max_iter: 65000 12 | weight_decay: 0.0005 13 | snapshot: 10000 14 | snapshot_prefix: "examples/mnist/mnist_autoencoder_adagrad_train" 15 | # solver mode: CPU or GPU 16 | solver_mode: GPU 17 | type: "AdaGrad" 18 | -------------------------------------------------------------------------------- /examples/mnist/mnist_autoencoder_solver_nesterov.prototxt: -------------------------------------------------------------------------------- 1 | net: "examples/mnist/mnist_autoencoder.prototxt" 2 | test_state: { stage: 'test-on-train' } 3 | test_iter: 500 4 | test_state: { stage: 'test-on-test' } 5 | test_iter: 100 6 | test_interval: 500 7 | test_compute_loss: true 8 | base_lr: 0.01 9 | lr_policy: "step" 10 | gamma: 0.1 11 | stepsize: 10000 12 | display: 100 13 | max_iter: 65000 14 | weight_decay: 0.0005 15 | snapshot: 10000 16 | snapshot_prefix: "examples/mnist/mnist_autoencoder_nesterov_train" 17 | momentum: 0.95 18 | # solver mode: CPU or GPU 19 | solver_mode: GPU 20 | type: "Nesterov" 21 | -------------------------------------------------------------------------------- /examples/mnist/train_lenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # 3 | # All modification made by Intel Corporation: © 2016 Intel Corporation 4 | # 5 | # All contributions by the University of California: 6 | # Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 7 | # All rights reserved. 8 | # 9 | # All other contributions: 10 | # Copyright (c) 2014, 2015, the respective contributors 11 | # All rights reserved. 12 | # For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 13 | # 14 | # 15 | # Redistribution and use in source and binary forms, with or without 16 | # modification, are permitted provided that the following conditions are met: 17 | # 18 | # * Redistributions of source code must retain the above copyright notice, 19 | # this list of conditions and the following disclaimer. 20 | # * Redistributions in binary form must reproduce the above copyright 21 | # notice, this list of conditions and the following disclaimer in the 22 | # documentation and/or other materials provided with the distribution. 23 | # * Neither the name of Intel Corporation nor the names of its contributors 24 | # may be used to endorse or promote products derived from this software 25 | # without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 31 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | # 38 | set -e 39 | 40 | ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt $@ 41 | -------------------------------------------------------------------------------- /examples/mnist/train_lenet_adam.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # 3 | # All modification made by Intel Corporation: © 2016 Intel Corporation 4 | # 5 | # All contributions by the University of California: 6 | # Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 7 | # All rights reserved. 8 | # 9 | # All other contributions: 10 | # Copyright (c) 2014, 2015, the respective contributors 11 | # All rights reserved. 12 | # For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 13 | # 14 | # 15 | # Redistribution and use in source and binary forms, with or without 16 | # modification, are permitted provided that the following conditions are met: 17 | # 18 | # * Redistributions of source code must retain the above copyright notice, 19 | # this list of conditions and the following disclaimer. 20 | # * Redistributions in binary form must reproduce the above copyright 21 | # notice, this list of conditions and the following disclaimer in the 22 | # documentation and/or other materials provided with the distribution. 23 | # * Neither the name of Intel Corporation nor the names of its contributors 24 | # may be used to endorse or promote products derived from this software 25 | # without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 31 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | # 38 | set -e 39 | 40 | ./build/tools/caffe train --solver=examples/mnist/lenet_solver_adam.prototxt $@ 41 | -------------------------------------------------------------------------------- /examples/mnist/train_lenet_rmsprop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # 3 | # All modification made by Intel Corporation: © 2016 Intel Corporation 4 | # 5 | # All contributions by the University of California: 6 | # Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 7 | # All rights reserved. 8 | # 9 | # All other contributions: 10 | # Copyright (c) 2014, 2015, the respective contributors 11 | # All rights reserved. 12 | # For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 13 | # 14 | # 15 | # Redistribution and use in source and binary forms, with or without 16 | # modification, are permitted provided that the following conditions are met: 17 | # 18 | # * Redistributions of source code must retain the above copyright notice, 19 | # this list of conditions and the following disclaimer. 20 | # * Redistributions in binary form must reproduce the above copyright 21 | # notice, this list of conditions and the following disclaimer in the 22 | # documentation and/or other materials provided with the distribution. 23 | # * Neither the name of Intel Corporation nor the names of its contributors 24 | # may be used to endorse or promote products derived from this software 25 | # without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 31 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | # 38 | set -e 39 | 40 | ./build/tools/caffe train \ 41 | --solver=examples/mnist/lenet_solver_rmsprop.prototxt $@ 42 | -------------------------------------------------------------------------------- /examples/net_surgery/conv.prototxt: -------------------------------------------------------------------------------- 1 | # Simple single-layer network to showcase editing model parameters. 2 | name: "convolution" 3 | layer { 4 | name: "data" 5 | type: "Input" 6 | top: "data" 7 | input_param { shape: { dim: 1 dim: 1 dim: 100 dim: 100 } } 8 | } 9 | layer { 10 | name: "conv" 11 | type: "Convolution" 12 | bottom: "data" 13 | top: "conv" 14 | convolution_param { 15 | num_output: 3 16 | kernel_size: 5 17 | stride: 1 18 | weight_filler { 19 | type: "gaussian" 20 | std: 0.01 21 | } 22 | bias_filler { 23 | type: "constant" 24 | value: 0 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/pycaffe/linreg.prototxt: -------------------------------------------------------------------------------- 1 | name: 'LinearRegressionExample' 2 | # define a simple network for linear regression on dummy data 3 | # that computes the loss by a PythonLayer. 4 | layer { 5 | type: 'DummyData' 6 | name: 'x' 7 | top: 'x' 8 | dummy_data_param { 9 | shape: { dim: 10 dim: 3 dim: 2 } 10 | data_filler: { type: 'gaussian' } 11 | } 12 | } 13 | layer { 14 | type: 'DummyData' 15 | name: 'y' 16 | top: 'y' 17 | dummy_data_param { 18 | shape: { dim: 10 dim: 3 dim: 2 } 19 | data_filler: { type: 'gaussian' } 20 | } 21 | } 22 | # include InnerProduct layers for parameters 23 | # so the net will need backward 24 | layer { 25 | type: 'InnerProduct' 26 | name: 'ipx' 27 | top: 'ipx' 28 | bottom: 'x' 29 | inner_product_param { 30 | num_output: 10 31 | weight_filler { type: 'xavier' } 32 | } 33 | } 34 | layer { 35 | type: 'InnerProduct' 36 | name: 'ipy' 37 | top: 'ipy' 38 | bottom: 'y' 39 | inner_product_param { 40 | num_output: 10 41 | weight_filler { type: 'xavier' } 42 | } 43 | } 44 | layer { 45 | type: 'Python' 46 | name: 'loss' 47 | top: 'loss' 48 | bottom: 'ipx' 49 | bottom: 'ipy' 50 | python_param { 51 | # the module name -- usually the filename -- that needs to be in $PYTHONPATH 52 | module: 'pyloss' 53 | # the layer name -- the class name in the module 54 | layer: 'EuclideanLossLayer' 55 | } 56 | # set loss weight so Caffe knows this is a loss layer. 57 | # since PythonLayer inherits directly from Layer, this isn't automatically 58 | # known to Caffe 59 | loss_weight: 1 60 | } 61 | -------------------------------------------------------------------------------- /examples/siamese/mnist_siamese.prototxt: -------------------------------------------------------------------------------- 1 | name: "mnist_siamese" 2 | layer { 3 | name: "data" 4 | type: "Input" 5 | top: "data" 6 | input_param { 7 | shape: { dim: 10000 dim: 1 dim: 28 dim: 28 } 8 | } 9 | } 10 | layer { 11 | name: "conv1" 12 | type: "Convolution" 13 | bottom: "data" 14 | top: "conv1" 15 | param { 16 | lr_mult: 1 17 | } 18 | param { 19 | lr_mult: 2 20 | } 21 | convolution_param { 22 | num_output: 20 23 | kernel_size: 5 24 | stride: 1 25 | } 26 | } 27 | layer { 28 | name: "pool1" 29 | type: "Pooling" 30 | bottom: "conv1" 31 | top: "pool1" 32 | pooling_param { 33 | pool: MAX 34 | kernel_size: 2 35 | stride: 2 36 | } 37 | } 38 | layer { 39 | name: "conv2" 40 | type: "Convolution" 41 | bottom: "pool1" 42 | top: "conv2" 43 | param { 44 | lr_mult: 1 45 | } 46 | param { 47 | lr_mult: 2 48 | } 49 | convolution_param { 50 | num_output: 50 51 | kernel_size: 5 52 | stride: 1 53 | } 54 | } 55 | layer { 56 | name: "pool2" 57 | type: "Pooling" 58 | bottom: "conv2" 59 | top: "pool2" 60 | pooling_param { 61 | pool: MAX 62 | kernel_size: 2 63 | stride: 2 64 | } 65 | } 66 | layer { 67 | name: "ip1" 68 | type: "InnerProduct" 69 | bottom: "pool2" 70 | top: "ip1" 71 | param { 72 | lr_mult: 1 73 | } 74 | param { 75 | lr_mult: 2 76 | } 77 | inner_product_param { 78 | num_output: 500 79 | } 80 | } 81 | layer { 82 | name: "relu1" 83 | type: "ReLU" 84 | bottom: "ip1" 85 | top: "ip1" 86 | } 87 | layer { 88 | name: "ip2" 89 | type: "InnerProduct" 90 | bottom: "ip1" 91 | top: "ip2" 92 | param { 93 | lr_mult: 1 94 | } 95 | param { 96 | lr_mult: 2 97 | } 98 | inner_product_param { 99 | num_output: 10 100 | } 101 | } 102 | layer { 103 | name: "feat" 104 | type: "InnerProduct" 105 | bottom: "ip2" 106 | top: "feat" 107 | param { 108 | lr_mult: 1 109 | } 110 | param { 111 | lr_mult: 2 112 | } 113 | inner_product_param { 114 | num_output: 2 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /examples/siamese/mnist_siamese_solver.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "examples/siamese/mnist_siamese_train_test.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 500 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0000 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 100 19 | # The maximum number of iterations 20 | max_iter: 50000 21 | # snapshot intermediate results 22 | snapshot: 5000 23 | snapshot_prefix: "examples/siamese/mnist_siamese" 24 | # solver mode: CPU or GPU 25 | solver_mode: GPU 26 | -------------------------------------------------------------------------------- /examples/ssd/images.txt: -------------------------------------------------------------------------------- 1 | examples/images/fish-bike.jpg 2 | -------------------------------------------------------------------------------- /examples/ssd/ssdvars.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export CAFFE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/../.. 3 | export PYTHONPATH=$CAFFE_ROOT/"python" 4 | 5 | # datapath is where you wish to store generated lmdb 6 | # also in $DATAPATH/data directory you should have unpacked 7 | # VOCdevkit and/or coco directories. see more in ./data/coco/README.md 8 | # this variable is used in create_list and create_data scripts only. 9 | export DATAPATH="/home/data/ssd/" 10 | 11 | echo CAFFE_ROOT is $CAFFE_ROOT 12 | echo PYTHONPATH is $PYTHONPATH 13 | echo DATAPATH is $DATAPATH 14 | -------------------------------------------------------------------------------- /examples/test_blobs/ImageDataLayerTest_TestRead_d.blob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/test_blobs/ImageDataLayerTest_TestRead_d.blob -------------------------------------------------------------------------------- /examples/test_blobs/ImageDataLayerTest_TestRead_f.blob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/test_blobs/ImageDataLayerTest_TestRead_f.blob -------------------------------------------------------------------------------- /examples/test_blobs/ImageDataLayerTest_TestResize_d.blob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/test_blobs/ImageDataLayerTest_TestResize_d.blob -------------------------------------------------------------------------------- /examples/test_blobs/ImageDataLayerTest_TestResize_f.blob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/test_blobs/ImageDataLayerTest_TestResize_f.blob -------------------------------------------------------------------------------- /examples/test_blobs/ImageDataLayerTest_TestShuffle_d.blob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/test_blobs/ImageDataLayerTest_TestShuffle_d.blob -------------------------------------------------------------------------------- /examples/test_blobs/ImageDataLayerTest_TestShuffle_f.blob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/examples/test_blobs/ImageDataLayerTest_TestShuffle_f.blob -------------------------------------------------------------------------------- /examples/video.list: -------------------------------------------------------------------------------- 1 | data.h5 2 | -------------------------------------------------------------------------------- /examples/web_demo/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Web demo 3 | description: Image classification demo running as a Flask web server. 4 | category: example 5 | include_in_docs: true 6 | priority: 10 7 | --- 8 | 9 | # Web Demo 10 | 11 | ## Requirements 12 | 13 | The demo server requires Python with some dependencies. 14 | To make sure you have the dependencies, please run `pip install -r examples/web_demo/requirements.txt`, and also make sure that you've compiled the Python Caffe interface and that it is on your `PYTHONPATH` (see [installation instructions](/installation.html)). 15 | 16 | Make sure that you have obtained the Reference CaffeNet Model and the ImageNet Auxiliary Data: 17 | 18 | ./scripts/download_model_binary.py models/bvlc_reference_caffenet 19 | ./data/ilsvrc12/get_ilsvrc_aux.sh 20 | 21 | NOTE: if you run into trouble, try re-downloading the auxiliary files. 22 | 23 | ## Run 24 | 25 | Running `python examples/web_demo/app.py` will bring up the demo server, accessible at `http://0.0.0.0:5000`. 26 | You can enable debug mode of the web server, or switch to a different port: 27 | 28 | % python examples/web_demo/app.py -h 29 | Usage: app.py [options] 30 | 31 | Options: 32 | -h, --help show this help message and exit 33 | -d, --debug enable debug mode 34 | -p PORT, --port=PORT which port to serve content on 35 | 36 | ## How are the "maximally accurate" results generated? 37 | 38 | In a nutshell: ImageNet predictions are made at the leaf nodes, but the organization of the project allows leaf nodes to be united via more general parent nodes, with 'entity' at the very top. 39 | To give "maximally accurate" results, we "back off" from maximally specific predictions to maintain a high accuracy. 40 | The `bet_file` that is loaded in the demo provides the graph structure and names of all relevant ImageNet nodes as well as measures of information gain between them. 41 | Please see the "Hedging your bets" paper from [CVPR 2012](http://www.image-net.org/projects/hedging/) for further information. 42 | -------------------------------------------------------------------------------- /examples/web_demo/requirements.txt: -------------------------------------------------------------------------------- 1 | werkzeug 2 | flask 3 | tornado 4 | numpy 5 | pandas 6 | pillow 7 | pyyaml 8 | -------------------------------------------------------------------------------- /include/caffe/util/float_compare.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/include/caffe/util/float_compare.hpp -------------------------------------------------------------------------------- /include/caffe/util/gpu_util.cuh: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_UTIL_GPU_UTIL_H_ 2 | #define CAFFE_UTIL_GPU_UTIL_H_ 3 | 4 | namespace caffe { 5 | 6 | template 7 | inline __device__ Dtype caffe_gpu_atomic_add(const Dtype val, Dtype* address); 8 | 9 | template <> 10 | inline __device__ 11 | float caffe_gpu_atomic_add(const float val, float* address) { 12 | return atomicAdd(address, val); 13 | } 14 | 15 | // double atomicAdd implementation taken from: 16 | // http://docs.nvidia.com/cuda/cuda-c-programming-guide/#axzz3PVCpVsEG 17 | template <> 18 | inline __device__ 19 | double caffe_gpu_atomic_add(const double val, double* address) { 20 | unsigned long long int* address_as_ull = // NOLINT(runtime/int) 21 | // NOLINT_NEXT_LINE(runtime/int) 22 | reinterpret_cast(address); 23 | unsigned long long int old = *address_as_ull; // NOLINT(runtime/int) 24 | unsigned long long int assumed; // NOLINT(runtime/int) 25 | do { 26 | assumed = old; 27 | old = atomicCAS(address_as_ull, assumed, 28 | __double_as_longlong(val + __longlong_as_double(assumed))); 29 | } while (assumed != old); 30 | return __longlong_as_double(old); 31 | } 32 | 33 | } // namespace caffe 34 | 35 | #endif // CAFFE_UTIL_GPU_UTIL_H_ 36 | -------------------------------------------------------------------------------- /matlab/+caffe/imagenet/ilsvrc_2012_mean.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/matlab/+caffe/imagenet/ilsvrc_2012_mean.mat -------------------------------------------------------------------------------- /matlab/+caffe/private/CHECK.m: -------------------------------------------------------------------------------- 1 | % 2 | % All modification made by Intel Corporation: Copyright (c) 2016 Intel Corporation 3 | % 4 | % All contributions by the University of California: 5 | % Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | % All rights reserved. 7 | % 8 | % All other contributions: 9 | % Copyright (c) 2014, 2015, the respective contributors 10 | % All rights reserved. 11 | % For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | % 13 | % 14 | % Redistribution and use in source and binary forms, with or without 15 | % modification, are permitted provided that the following conditions are met: 16 | % 17 | % * Redistributions of source code must retain the above copyright notice, 18 | % this list of conditions and the following disclaimer. 19 | % * Redistributions in binary form must reproduce the above copyright 20 | % notice, this list of conditions and the following disclaimer in the 21 | % documentation and/or other materials provided with the distribution. 22 | % * Neither the name of Intel Corporation nor the names of its contributors 23 | % may be used to endorse or promote products derived from this software 24 | % without specific prior written permission. 25 | % 26 | % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | % DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | % FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | % DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | % SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | % CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | % OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | % OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | % 37 | function CHECK(expr, error_msg) 38 | 39 | if ~expr 40 | error(error_msg); 41 | end 42 | 43 | end 44 | -------------------------------------------------------------------------------- /matlab/+caffe/set_mode_cpu.m: -------------------------------------------------------------------------------- 1 | % 2 | % All modification made by Intel Corporation: Copyright (c) 2016 Intel Corporation 3 | % 4 | % All contributions by the University of California: 5 | % Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | % All rights reserved. 7 | % 8 | % All other contributions: 9 | % Copyright (c) 2014, 2015, the respective contributors 10 | % All rights reserved. 11 | % For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | % 13 | % 14 | % Redistribution and use in source and binary forms, with or without 15 | % modification, are permitted provided that the following conditions are met: 16 | % 17 | % * Redistributions of source code must retain the above copyright notice, 18 | % this list of conditions and the following disclaimer. 19 | % * Redistributions in binary form must reproduce the above copyright 20 | % notice, this list of conditions and the following disclaimer in the 21 | % documentation and/or other materials provided with the distribution. 22 | % * Neither the name of Intel Corporation nor the names of its contributors 23 | % may be used to endorse or promote products derived from this software 24 | % without specific prior written permission. 25 | % 26 | % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | % DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | % FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | % DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | % SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | % CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | % OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | % OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | % 37 | function set_mode_cpu() 38 | % set_mode_cpu() 39 | % set Caffe to CPU mode 40 | 41 | caffe_('set_mode_cpu'); 42 | 43 | end 44 | -------------------------------------------------------------------------------- /matlab/+caffe/set_mode_gpu.m: -------------------------------------------------------------------------------- 1 | % 2 | % All modification made by Intel Corporation: Copyright (c) 2016 Intel Corporation 3 | % 4 | % All contributions by the University of California: 5 | % Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | % All rights reserved. 7 | % 8 | % All other contributions: 9 | % Copyright (c) 2014, 2015, the respective contributors 10 | % All rights reserved. 11 | % For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | % 13 | % 14 | % Redistribution and use in source and binary forms, with or without 15 | % modification, are permitted provided that the following conditions are met: 16 | % 17 | % * Redistributions of source code must retain the above copyright notice, 18 | % this list of conditions and the following disclaimer. 19 | % * Redistributions in binary form must reproduce the above copyright 20 | % notice, this list of conditions and the following disclaimer in the 21 | % documentation and/or other materials provided with the distribution. 22 | % * Neither the name of Intel Corporation nor the names of its contributors 23 | % may be used to endorse or promote products derived from this software 24 | % without specific prior written permission. 25 | % 26 | % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | % DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | % FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | % DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | % SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | % CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | % OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | % OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | % 37 | function set_mode_gpu() 38 | % set_mode_gpu() 39 | % set Caffe to GPU mode 40 | 41 | caffe_('set_mode_gpu'); 42 | 43 | end 44 | -------------------------------------------------------------------------------- /matlab/hdf5creation/.gitignore: -------------------------------------------------------------------------------- 1 | *.h5 2 | list.txt 3 | -------------------------------------------------------------------------------- /mkldnn.commit: -------------------------------------------------------------------------------- 1 | b01e3a55a07be62172e713bcd2644c5176360212 2 | -------------------------------------------------------------------------------- /models/bvlc_alexnet/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BVLC AlexNet Model 3 | caffemodel: bvlc_alexnet.caffemodel 4 | caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel 5 | license: unrestricted 6 | sha1: 9116a64c0fbe4459d18f4bb6b56d647b63920377 7 | caffe_commit: 709dc15af4a06bebda027c1eb2b3f3e3375d5077 8 | --- 9 | 10 | This model is a replication of the model described in the [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks) publication. 11 | 12 | Differences: 13 | - not training with the relighting data-augmentation; 14 | - initializing non-zero biases to 0.1 instead of 1 (found necessary for training, as initialization to 1 gave flat loss). 15 | 16 | The bundled model is the iteration 360,000 snapshot. 17 | The best validation performance during training was iteration 358,000 with validation accuracy 57.258% and loss 1.83948. 18 | This model obtains a top-1 accuracy 57.1% and a top-5 accuracy 80.2% on the validation set, using just the center crop. 19 | (Using the average of 10 crops, (4 + 1 center) * 2 mirror, should obtain a bit higher accuracy.) 20 | 21 | This model was trained by Evan Shelhamer @shelhamer 22 | 23 | ## License 24 | 25 | This model is released for unrestricted use. 26 | -------------------------------------------------------------------------------- /models/bvlc_alexnet/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/bvlc_alexnet/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 1000 4 | base_lr: 0.01 5 | lr_policy: "step" 6 | gamma: 0.1 7 | stepsize: 100000 8 | display: 20 9 | max_iter: 450000 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 10000 13 | snapshot_prefix: "models/bvlc_alexnet/caffe_alexnet_train" 14 | solver_mode: CPU 15 | -------------------------------------------------------------------------------- /models/bvlc_alexnet/solver_client.prototxt: -------------------------------------------------------------------------------- 1 | train_net: "models/bvlc_alexnet/train_val_client.prototxt" 2 | base_lr: 0.01 3 | lr_policy: "step" 4 | gamma: 0.1 5 | stepsize: 100000 6 | display: 1 7 | max_iter: 450000 8 | momentum: 0.9 9 | weight_decay: 0.0005 10 | solver_mode: CPU 11 | -------------------------------------------------------------------------------- /models/bvlc_alexnet/solver_param_server.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/bvlc_alexnet/train_val_param_server.prototxt" 2 | test_iter: 1000 3 | test_interval: 1000 4 | base_lr: 0.01 5 | lr_policy: "step" 6 | gamma: 0.1 7 | stepsize: 100000 8 | display: 20 9 | max_iter: 450000 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 10000 13 | snapshot_prefix: "models/bvlc_alexnet/caffe_alexnet_train" 14 | solver_mode: CPU 15 | -------------------------------------------------------------------------------- /models/bvlc_googlenet/quick_solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/bvlc_googlenet/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 4000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.01 8 | lr_policy: "poly" 9 | power: 0.5 10 | max_iter: 2400000 11 | momentum: 0.9 12 | weight_decay: 0.0002 13 | snapshot: 40000 14 | snapshot_prefix: "models/bvlc_googlenet/bvlc_googlenet_quick" 15 | solver_mode: GPU 16 | -------------------------------------------------------------------------------- /models/bvlc_googlenet/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BVLC GoogleNet Model 3 | caffemodel: bvlc_googlenet.caffemodel 4 | caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel 5 | license: unrestricted 6 | sha1: 405fc5acd08a3bb12de8ee5e23a96bec22f08204 7 | caffe_commit: bc614d1bd91896e3faceaf40b23b72dab47d44f5 8 | --- 9 | 10 | This model is a replication of the model described in the [GoogleNet](http://arxiv.org/abs/1409.4842) publication. We would like to thank Christian Szegedy for all his help in the replication of GoogleNet model. 11 | 12 | Differences: 13 | - not training with the relighting data-augmentation; 14 | - not training with the scale or aspect-ratio data-augmentation; 15 | - uses "xavier" to initialize the weights instead of "gaussian"; 16 | - quick_solver.prototxt uses a different learning rate decay policy than the original solver.prototxt, that allows a much faster training (60 epochs vs 250 epochs); 17 | 18 | The bundled model is the iteration 2,400,000 snapshot (60 epochs) using quick_solver.prototxt 19 | 20 | This bundled model obtains a top-1 accuracy 68.7% (31.3% error) and a top-5 accuracy 88.9% (11.1% error) on the validation set, using just the center crop. 21 | (Using the average of 10 crops, (4 + 1 center) * 2 mirror, should obtain a bit higher accuracy.) 22 | 23 | Timings for bvlc_googlenet with cuDNN using batch_size:128 on a K40c: 24 | - Average Forward pass: 562.841 ms. 25 | - Average Backward pass: 1123.84 ms. 26 | - Average Forward-Backward: 1688.8 ms. 27 | 28 | This model was trained by Sergio Guadarrama @sguada 29 | 30 | ## License 31 | 32 | This model is released for unrestricted use. 33 | -------------------------------------------------------------------------------- /models/bvlc_googlenet/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/bvlc_googlenet/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 4000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.01 8 | lr_policy: "step" 9 | stepsize: 320000 10 | gamma: 0.96 11 | max_iter: 10000000 12 | momentum: 0.9 13 | weight_decay: 0.0002 14 | snapshot: 40000 15 | snapshot_prefix: "models/bvlc_googlenet/bvlc_googlenet" 16 | solver_mode: GPU 17 | -------------------------------------------------------------------------------- /models/bvlc_googlenet/solver_client.prototxt: -------------------------------------------------------------------------------- 1 | train_net: "models/bvlc_googlenet/train_val_client.prototxt" 2 | display: 40 3 | average_loss: 40 4 | base_lr: 0.06 5 | lr_policy: "poly" 6 | power: 0.5 7 | max_iter: 91000 8 | momentum: 0.9 9 | weight_decay: 0.0002 10 | solver_mode: CPU 11 | snapshot: 10000 12 | snapshot_prefix: "multinode_googlenet_91k" 13 | -------------------------------------------------------------------------------- /models/bvlc_googlenet/solver_param_server.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/bvlc_googlenet/train_val_param_server.prototxt" 2 | test_iter: 1000 3 | test_interval: 4000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.08 8 | lr_policy: "poly" 9 | power: 0.5 10 | max_iter: 2400000 11 | momentum: 0.9 12 | weight_decay: 0.0002 13 | snapshot: 40000 14 | snapshot_prefix: "models/bvlc_googlenet/bvlc_googlenet_multinode" 15 | solver_mode: CPU 16 | -------------------------------------------------------------------------------- /models/bvlc_reference_caffenet/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BVLC CaffeNet Model 3 | caffemodel: bvlc_reference_caffenet.caffemodel 4 | caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel 5 | license: unrestricted 6 | sha1: 4c8d77deb20ea792f84eb5e6d0a11ca0a8660a46 7 | caffe_commit: 709dc15af4a06bebda027c1eb2b3f3e3375d5077 8 | --- 9 | 10 | This model is the result of following the Caffe [ImageNet model training instructions](http://caffe.berkeleyvision.org/gathered/examples/imagenet.html). 11 | It is a replication of the model described in the [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks) publication with some differences: 12 | 13 | - not training with the relighting data-augmentation; 14 | - the order of pooling and normalization layers is switched (in CaffeNet, pooling is done before normalization). 15 | 16 | This model is snapshot of iteration 310,000. 17 | The best validation performance during training was iteration 313,000 with validation accuracy 57.412% and loss 1.82328. 18 | This model obtains a top-1 accuracy 57.4% and a top-5 accuracy 80.4% on the validation set, using just the center crop. 19 | (Using the average of 10 crops, (4 + 1 center) * 2 mirror, should obtain a bit higher accuracy still.) 20 | 21 | This model was trained by Jeff Donahue @jeffdonahue 22 | 23 | ## License 24 | 25 | This model is released for unrestricted use. 26 | -------------------------------------------------------------------------------- /models/bvlc_reference_caffenet/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/bvlc_reference_caffenet/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 1000 4 | base_lr: 0.01 5 | lr_policy: "step" 6 | gamma: 0.1 7 | stepsize: 100000 8 | display: 20 9 | max_iter: 450000 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 10000 13 | snapshot_prefix: "models/bvlc_reference_caffenet/caffenet_train" 14 | solver_mode: CPU 15 | -------------------------------------------------------------------------------- /models/bvlc_reference_rcnn_ilsvrc13/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BVLC Reference RCNN ILSVRC13 Model 3 | caffemodel: bvlc_reference_rcnn_ilsvrc13.caffemodel 4 | caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_reference_rcnn_ilsvrc13.caffemodel 5 | license: unrestricted 6 | sha1: bdd8abb885819cba5e2fe1eb36235f2319477e64 7 | caffe_commit: a7e397abbda52c0b90323c23ab95bdeabee90a98 8 | --- 9 | 10 | The pure Caffe instantiation of the [R-CNN](https://github.com/rbgirshick/rcnn) model for ILSVRC13 detection. 11 | This model was made by transplanting the R-CNN SVM classifiers into a `fc-rcnn` classification layer, provided here as an off-the-shelf Caffe detector. 12 | Try the [detection example](http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/detection.ipynb) to see it in action. 13 | 14 | *N.B. For research purposes, make use of the official R-CNN package and not this example.* 15 | 16 | This model was trained by Ross Girshick @rbgirshick 17 | 18 | ## License 19 | 20 | This model is released for unrestricted use. 21 | -------------------------------------------------------------------------------- /models/default_googlenet_v2/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/default_googlenet_v2/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.045 8 | lr_policy: "step" 9 | stepsize: 6400 10 | gamma: 0.96 11 | max_iter: 1200000 12 | momentum: 0.9 13 | weight_decay: 0.0002 14 | snapshot: 50000 15 | snapshot_prefix: "models/default_googlenet_v2/default_googlenet_v2" 16 | solver_mode: CPU 17 | -------------------------------------------------------------------------------- /models/default_resnet_50/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Shaoqing Ren 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /models/default_resnet_50/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/default_resnet_50/train_val.prototxt" 2 | test_iter: 100 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.1 8 | lr_policy: "step" 9 | stepsize: 320000 10 | gamma: 0.96 11 | max_iter: 600000 12 | momentum: 0.9 13 | weight_decay: 0.0001 14 | snapshot: 50000 15 | snapshot_prefix: "models/default_resnet_50/default_resnet_50" 16 | solver_mode: CPU 17 | -------------------------------------------------------------------------------- /models/default_vgg_16/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/default_vgg_16/train_val.prototxt" 2 | 3 | test_iter: 100 4 | test_interval: 10000 5 | momentum: 0.9 6 | weight_decay: 0.0005 7 | base_lr: 0.01 8 | lr_policy: "step" 9 | gamma: 0.1 10 | stepsize: 100000 11 | max_iter: 350000 12 | display: 20 13 | snapshot: 35000 14 | solver_mode: CPU 15 | snapshot_prefix: "models/default_vgg_16/default_vgg_16" 16 | 17 | -------------------------------------------------------------------------------- /models/default_vgg_19/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/default_vgg_19/train_val.prototxt" 2 | 3 | test_iter: 100 4 | test_interval: 10000 5 | momentum: 0.9 6 | weight_decay: 0.0005 7 | base_lr: 0.01 8 | lr_policy: "step" 9 | gamma: 0.1 10 | stepsize: 100000 11 | max_iter: 350000 12 | display: 20 13 | snapshot: 35000 14 | solver_mode: CPU 15 | snapshot_prefix: "models/default_vgg_19/default_vgg_19" 16 | 17 | -------------------------------------------------------------------------------- /models/finetune_flickr_style/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Finetuning CaffeNet on Flickr Style 3 | caffemodel: finetune_flickr_style.caffemodel 4 | caffemodel_url: http://dl.caffe.berkeleyvision.org/finetune_flickr_style.caffemodel 5 | license: non-commercial 6 | sha1: b61b5cef7d771b53b0c488e78d35ccadc073e9cf 7 | caffe_commit: 737ea5e936821b5c69f9c3952d72693ae5843370 8 | gist_id: 034c6ac3865563b69e60 9 | --- 10 | 11 | This model is trained exactly as described in `docs/finetune_flickr_style/readme.md`, using all 80000 images. 12 | The final performance: 13 | 14 | I1017 07:36:17.370688 31333 solver.cpp:228] Iteration 100000, loss = 0.757952 15 | I1017 07:36:17.370730 31333 solver.cpp:247] Iteration 100000, Testing net (#0) 16 | I1017 07:36:34.248730 31333 solver.cpp:298] Test net output #0: accuracy = 0.3916 17 | 18 | This model was trained by Sergey Karayev @sergeyk 19 | 20 | ## License 21 | 22 | The Flickr Style dataset contains only URLs to images. 23 | Some of the images may have copyright. 24 | Training a category-recognition model for research/non-commercial use may constitute fair use of this data, but the result should not be used for commercial purposes. 25 | -------------------------------------------------------------------------------- /models/finetune_flickr_style/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/finetune_flickr_style/train_val.prototxt" 2 | test_iter: 100 3 | test_interval: 1000 4 | # lr for fine-tuning should be lower than when starting from scratch 5 | base_lr: 0.001 6 | lr_policy: "step" 7 | gamma: 0.1 8 | # stepsize should also be lower, as we're closer to being done 9 | stepsize: 20000 10 | display: 20 11 | max_iter: 100000 12 | momentum: 0.9 13 | weight_decay: 0.0005 14 | snapshot: 10000 15 | snapshot_prefix: "models/finetune_flickr_style/finetune_flickr_style" 16 | # uncomment the following to default to CPU mode solving 17 | solver_mode: CPU 18 | -------------------------------------------------------------------------------- /models/intel_optimized_models/alexnet/solver.prototxt: -------------------------------------------------------------------------------- 1 | #This is Intel(R) optimized (in terms of time to train) version of solver for model described in the [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks) publication. 2 | #Original solver.prototxt can be found in /models/bvlc_alexnet/ directory of this repository. 3 | #Differences: 4 | #- lr_policy is set to poly instead of step 5 | #- base_lr is decreased to 0.007 6 | #- max_iter is decreased to 250000 7 | #- power is set to 0.6 8 | # 9 | #Top-5 and Top-1 results achieved with this version of solver: 10 | #Top-5: 80.4% 11 | #Top-1: 57.4% 12 | #Training was performed using server equipped with Intel(R) Xeon Phi(TM) CPU 7250 processor. 13 | net: "models/intel_optimized_models/alexnet/train_val.prototxt" 14 | test_iter: 1000 15 | test_interval: 10000 16 | base_lr: 0.007 17 | lr_policy: "poly" 18 | power: 0.6 19 | display: 20 20 | max_iter: 250000 21 | momentum: 0.9 22 | weight_decay: 0.0005 23 | snapshot: 50000 24 | snapshot_prefix: "models/intel_optimized_models/alexnet/alexnet_train" 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /models/intel_optimized_models/alexnet/solver_gabor_init.prototxt: -------------------------------------------------------------------------------- 1 | #This is Intel(R) optimized (in terms of time to train) version of solver for model described in the [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks) publication. 2 | #Original solver.prototxt can be found in /models/bvlc_alexnet/ directory of this repository. 3 | #Differences: 4 | #- lr_policy is set to poly instead of step 5 | #- base_lr is decreased to 0.007 6 | #- max_iter is decreased to 200000 7 | #- power is set to 0.65 8 | #- net parameter is set to train_val_gabor_init.prototxt 9 | # 10 | #Top-5 and Top-1 results achieved with this version of solver: 11 | #Top-5: 80.02% 12 | #Top-1: 56.8% 13 | #Training was performed using server equipped with Intel(R) Xeon Phi(TM) CPU 7250 processor. 14 | net: "models/intel_optimized_models/alexnet/train_val_gabor_init.prototxt" 15 | test_iter: 1000 16 | test_interval: 10000 17 | base_lr: 0.007 18 | lr_policy: "poly" 19 | power: 0.65 20 | display: 20 21 | max_iter: 200000 22 | momentum: 0.9 23 | weight_decay: 0.0005 24 | snapshot: 50000 25 | snapshot_prefix: "models/intel_optimized_models/alexnet/alexnet_train" 26 | solver_mode: CPU 27 | -------------------------------------------------------------------------------- /models/intel_optimized_models/googlenet/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/intel_optimized_models/googlenet/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.012 8 | lr_policy: "poly" 9 | power: 0.5 10 | max_iter: 800000 11 | momentum: 0.9 12 | weight_decay: 0.0002 13 | snapshot: 40000 14 | snapshot_prefix: "models/intel_optimized_models/googlenet/googlenet" 15 | solver_mode: CPU 16 | -------------------------------------------------------------------------------- /models/intel_optimized_models/googlenet_v2/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/intel_optimized_models/googlenet_v2/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.045 8 | lr_policy: "step" 9 | stepsize: 2133 10 | gamma: 0.96 11 | max_iter: 400000 12 | momentum: 0.9 13 | weight_decay: 0.0002 14 | snapshot: 50000 15 | snapshot_prefix: "models/intel_optimized_models/googlenet_v2/googlenet_v2" 16 | solver_mode: CPU 17 | -------------------------------------------------------------------------------- /models/intel_optimized_models/multinode/alexnet_4nodes/solver.prototxt: -------------------------------------------------------------------------------- 1 | #This is Intel(R) optimized (in terms of time to train) version of solver for model described in the [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks) publication. 2 | #Original solver.prototxt can be found in /models/bvlc_alexnet/ directory of this repository. 3 | #Differences: 4 | #- lr_policy is set to poly instead of step 5 | #- base_lr is decreased to 0.06 6 | #- max_iter is decreased to 110000 7 | #- power is set to 0.6 8 | # 9 | #Top-5 and Top-1 results achieved with this version of solver: 10 | #Top-5: 80.36% 11 | #Top-1: 57.51% 12 | #Training was performed using server equipped with Intel(R) Xeon Phi(TM) CPU 7250 processor. 13 | net: "models/intel_optimized_models/multinode/alexnet_4nodes/train_val.prototxt" 14 | #test_iter: 1000 15 | #test_interval: 10000 16 | base_lr: 0.06 17 | lr_policy: "poly" 18 | power: 0.6 19 | display: 200 20 | max_iter: 110000 21 | momentum: 0.9 22 | weight_decay: 0.0005 23 | snapshot: 25000 24 | snapshot_prefix: "models/intel_optimized_models/multinode/alexnet_4nodes/alexnet_train" 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /models/intel_optimized_models/multinode/googlenet_4nodes/solver.prototxt: -------------------------------------------------------------------------------- 1 | #This is Intel(R) optimized (in terms of time to train) version of solver for model described in the [GoogLeNet](http://arxiv.org/abs/1409.4842) publication. 2 | #Original solver.prototxt can be found in /models/bvlc_googlenet/ directory of this repository. 3 | #Differences: 4 | #- base_lr is set to 0.04 5 | #- max_iter is set to 350000 6 | # 7 | #- bias_filler value changed to 0.1 8 | # 9 | #Top-5 and Top-1 results achieved with this version of solver: 10 | #Top-5: 89.06% 11 | #Top-1: 68.74% 12 | #Training was performed using server equipped with Intel(R) Xeon Phi(TM) CPU 7250 processor. 13 | net: "models/intel_optimized_models/multinode/googlenet_4nodes/train_val.prototxt" 14 | #test_iter: 1000 15 | #test_interval: 10000 16 | #test_initialization: false 17 | display: 40 18 | average_loss: 40 19 | base_lr: 0.04 20 | lr_policy: "poly" 21 | power: 0.5 22 | max_iter: 450000 23 | momentum: 0.9 24 | weight_decay: 0.0002 25 | snapshot: 50000 26 | snapshot_prefix: "models/intel_optimized_models/multinode/googlenet_4nodes/googlenet" 27 | solver_mode: CPU 28 | -------------------------------------------------------------------------------- /models/intel_optimized_models/multinode/googlenet_8nodes/solver.prototxt: -------------------------------------------------------------------------------- 1 | #This is Intel(R) optimized (in terms of time to train) version of solver for model described in the [GoogLeNet](http://arxiv.org/abs/1409.4842) publication. 2 | #Original solver.prototxt can be found in /models/bvlc_googlenet/ directory of this repository. 3 | #Differences: 4 | #- base_lr is set to 0.06 5 | #- max_iter is set to 182000 6 | # 7 | #- bias_filler value changed to 0.1 8 | # 9 | #Top-5 and Top-1 results achieved with this version of solver: 10 | #Top-5: 88.85% 11 | #Top-1: 68.58% 12 | #Training was performed using server equipped with Intel(R) Xeon Phi(TM) CPU 7250 processor. 13 | net: "models/intel_optimized_models/multinode/googlenet_8nodes/train_val.prototxt" 14 | #test_iter: 1000 15 | #test_interval: 10000 16 | #test_initialization: false 17 | display: 40 18 | average_loss: 40 19 | base_lr: 0.06 20 | lr_policy: "poly" 21 | power: 0.5 22 | max_iter: 182000 23 | momentum: 0.9 24 | weight_decay: 0.0002 25 | snapshot: 50000 26 | snapshot_prefix: "models/intel_optimized_models/multinode/googlenet_8nodes/googlenet" 27 | solver_mode: CPU 28 | -------------------------------------------------------------------------------- /models/intel_optimized_models/multinode/googlenet_v2_8nodes/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/intel_optimized_models/multinode/googlenet_v2_8nodes/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 10000 4 | test_initialization: false 5 | base_lr: 0.06 6 | display: 40 7 | max_iter: 182000 8 | lr_policy: "poly" 9 | power: 0.5 10 | momentum: 0.9 11 | weight_decay: 0.0002 12 | snapshot: 10000 13 | snapshot_prefix: "models/intel_optimized_models/multinode/googlenet_v2_8nodes/default_googlenet_v2" 14 | solver_mode: CPU 15 | average_loss: 40 16 | -------------------------------------------------------------------------------- /models/intel_optimized_models/multinode/resnet_50_256_nodes_8k_batch/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/intel_optimized_models/multinode/resnet_50_256_nodes_8k_batch/train_val.prototxt" 2 | test_iter: 1000 3 | test_interval: 156 4 | test_initialization: false 5 | display: 40 6 | base_lr: 3.2 7 | lr_policy: "multistep" 8 | stepvalue:4680 9 | stepvalue:9360 10 | stepvalue:12480 11 | gamma: 0.1 12 | max_iter: 14075 13 | warmup_iter: 780 # 1281167 / 8192 * 5 epochs 14 | warmup_start_lr: 0.1 15 | momentum: 0.9 16 | weight_decay: 0.0001 17 | snapshot: 156 18 | snapshot_prefix: "models/intel_optimized_models/multinode/resnet_50_256_nodes_8k_batch/resnet_50_256_nodes_8k" 19 | solver_mode: CPU 20 | -------------------------------------------------------------------------------- /models/intel_optimized_models/multinode/vgg_16_8nodes/solver.prototxt: -------------------------------------------------------------------------------- 1 | net: "models/intel_optimized_models/multinode/vgg_16_8nodes/train_val.prototxt" 2 | test_iter: 1563 3 | test_interval: 10000 4 | momentum: 0.9 5 | weight_decay: 0.0005 6 | base_lr: 0.01 7 | lr_policy: "poly" 8 | power: 2 9 | max_iter: 300000 10 | display: 40 11 | snapshot: 100000 12 | solver_mode: CPU 13 | snapshot_prefix: "models/intel_optimized_models/multinode/vgg_16_8nodes" 14 | 15 | -------------------------------------------------------------------------------- /models/intel_optimized_models/resnet_50/solver.prototxt: -------------------------------------------------------------------------------- 1 | #This solver is described by Computer Vision Group Jena (CVGJ) in [ImageNet pre-trained models with batch normalization] (https://arxiv.org/pdf/1612.01452.pdf) 2 | net: "models/intel_optimized_models/resnet_50/train_val.prototxt" 3 | test_iter: 5000 4 | test_interval: 15000 5 | base_lr: 0.1 6 | display: 20 7 | iter_size: 2 8 | max_iter: 320000 9 | lr_policy: "poly" 10 | power: 1 11 | momentum: 0.9 12 | weight_decay: 0.0001 13 | snapshot: 30000 14 | snapshot_prefix: "models/intel_optimized_models/resnet_50/caffe-resnet50" 15 | test_initialization: false 16 | solver_mode: CPU 17 | 18 | -------------------------------------------------------------------------------- /models/intel_optimized_models/ssd/AlexNet/VOC0712/SSD_300x300/solver.prototxt: -------------------------------------------------------------------------------- 1 | train_net: "examples/ssd/AlexNet/VOC0712/SSD_300x300/train.prototxt" 2 | test_net: "examples/ssd/AlexNet/VOC0712/SSD_300x300/test.prototxt" 3 | test_iter: 619 4 | test_interval: 10000 5 | base_lr: 0.00025 6 | display: 10 7 | max_iter: 120000 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 80000 13 | snapshot_prefix: "examples/ssd/AlexNet/VOC0712/SSD_300x300/AlexNet_VOC0712_SSD_300x300" 14 | solver_mode: CPU 15 | device_id: 0 16 | debug_info: false 17 | snapshot_after_train: true 18 | test_initialization: false 19 | average_loss: 10 20 | stepvalue: 80000 21 | stepvalue: 100000 22 | stepvalue: 120000 23 | iter_size: 1 24 | type: "SGD" 25 | eval_type: "detection" 26 | ap_version: "11point" 27 | 28 | -------------------------------------------------------------------------------- /models/intel_optimized_models/ssd/VGGNet/VOC0712/SSD_300x300/solver.prototxt: -------------------------------------------------------------------------------- 1 | train_net: "models/intel_optimized_models/ssd/VGGNet/VOC0712/SSD_300x300/train.prototxt" 2 | test_net: "models/intel_optimized_models/ssd/VGGNet/VOC0712/SSD_300x300/test.prototxt" 3 | test_iter: 619 4 | test_interval: 10000 5 | base_lr: 0.001 6 | display: 10 7 | max_iter: 120000 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 80000 13 | snapshot_prefix: "models/intel_optimized_models/ssd/VGGNet/VOC0712/SSD_300x300/VGG_VOC0712_SSD_300x300" 14 | solver_mode: CPU 15 | device_id: 0 16 | debug_info: false 17 | snapshot_after_train: true 18 | test_initialization: false 19 | average_loss: 10 20 | stepvalue: 80000 21 | stepvalue: 100000 22 | stepvalue: 120000 23 | iter_size: 1 24 | type: "SGD" 25 | eval_type: "detection" 26 | ap_version: "11point" 27 | 28 | 29 | -------------------------------------------------------------------------------- /models/intel_optimized_models/ssd/VGGNet/coco/SSD_300x300/solver.prototxt: -------------------------------------------------------------------------------- 1 | train_net: "models/intel_optimized_models/ssd/VGGNet/coco/SSD_300x300/train.prototxt" 2 | test_net: "models/intel_optimized_models/ssd/VGGNet/coco/SSD_300x300/test.prototxt" 3 | test_iter: 625 4 | test_interval: 10000 5 | base_lr: 0.001 6 | display: 10 7 | max_iter: 400000 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | momentum: 0.9 11 | weight_decay: 0.0005 12 | snapshot: 40000 13 | snapshot_prefix: "models/intel_optimized_models/ssd/VGGNet/coco/SSD_300x300/VGG_coco_SSD_300x300" 14 | solver_mode: CPU 15 | device_id: 0 16 | debug_info: false 17 | snapshot_after_train: true 18 | test_initialization: false 19 | average_loss: 10 20 | stepvalue: 280000 21 | stepvalue: 360000 22 | stepvalue: 400000 23 | iter_size: 1 24 | type: "SGD" 25 | eval_type: "detection" 26 | ap_version: "11point" 27 | 28 | -------------------------------------------------------------------------------- /python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT HAVE_PYTHON) 2 | message(STATUS "Python interface is disabled or not all required dependencies found. Building without it...") 3 | return() 4 | endif() 5 | 6 | file(GLOB_RECURSE python_srcs ${PROJECT_SOURCE_DIR}/python/*.cpp) 7 | 8 | add_library(pycaffe SHARED ${python_srcs}) 9 | caffe_default_properties(pycaffe) 10 | set_target_properties(pycaffe PROPERTIES PREFIX "" OUTPUT_NAME "_caffe") 11 | target_include_directories(pycaffe PUBLIC ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR}) 12 | target_link_libraries(pycaffe PUBLIC ${Caffe_LINK} ${PYTHON_LIBRARIES}) 13 | 14 | if(UNIX OR APPLE) 15 | set(__linkname "${PROJECT_SOURCE_DIR}/python/caffe/_caffe.so") 16 | add_custom_command(TARGET pycaffe POST_BUILD 17 | COMMAND ln -sf $ "${__linkname}" 18 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/python/caffe/proto 19 | COMMAND touch ${PROJECT_SOURCE_DIR}/python/caffe/proto/__init__.py 20 | COMMAND cp ${proto_gen_folder}/*.py ${PROJECT_SOURCE_DIR}/python/caffe/proto/ 21 | COMMENT "Creating symlink ${__linkname} -> ${PROJECT_BINARY_DIR}/lib/_caffe${Caffe_POSTFIX}.so") 22 | endif() 23 | 24 | # ---[ Install 25 | # scripts 26 | file(GLOB python_files *.py requirements.txt) 27 | install(FILES ${python_files} DESTINATION python) 28 | 29 | # module 30 | install(DIRECTORY caffe 31 | DESTINATION python 32 | FILES_MATCHING 33 | PATTERN "*.py" 34 | PATTERN "ilsvrc_2012_mean.npy" 35 | PATTERN "test" EXCLUDE 36 | ) 37 | 38 | # _caffe.so 39 | install(TARGETS pycaffe DESTINATION python/caffe) 40 | 41 | -------------------------------------------------------------------------------- /python/caffe/imagenet/ilsvrc_2012_mean.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/python/caffe/imagenet/ilsvrc_2012_mean.npy -------------------------------------------------------------------------------- /python/caffe/test/test_draw.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | from google.protobuf import text_format 5 | 6 | import caffe.draw 7 | from caffe.proto import caffe_pb2 8 | 9 | def getFilenames(): 10 | """Yields files in the source tree which are Net prototxts.""" 11 | result = [] 12 | 13 | root_dir = os.path.abspath(os.path.join( 14 | os.path.dirname(__file__), '..', '..', '..')) 15 | assert os.path.exists(root_dir) 16 | 17 | for dirname in ('models', 'examples'): 18 | dirname = os.path.join(root_dir, dirname) 19 | assert os.path.exists(dirname) 20 | for cwd, _, filenames in os.walk(dirname): 21 | for filename in filenames: 22 | filename = os.path.join(cwd, filename) 23 | if filename.endswith('.prototxt') and 'solver' not in filename: 24 | yield os.path.join(dirname, filename) 25 | 26 | 27 | class TestDraw(unittest.TestCase): 28 | def test_draw_net(self): 29 | for filename in getFilenames(): 30 | net = caffe_pb2.NetParameter() 31 | with open(filename) as infile: 32 | text_format.Merge(infile.read(), net) 33 | caffe.draw.draw_net(net, 'LR') 34 | 35 | 36 | if __name__ == "__main__": 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /python/requirements.txt: -------------------------------------------------------------------------------- 1 | Cython>=0.19.2 2 | numpy>=1.7.1 3 | scipy>=0.13.2 4 | scikit-image>=0.9.3 5 | matplotlib>=1.3.1 6 | ipython>=3.0.0 7 | h5py>=2.2.0 8 | leveldb>=0.191 9 | networkx>=1.8.1 10 | nose>=1.3.0 11 | pandas>=0.12.0 12 | python-dateutil>=1.4,<2 13 | protobuf>=2.5.0 14 | python-gflags>=2.0 15 | pyyaml>=3.10 16 | Pillow>=2.3.0 17 | six>=1.1.0 -------------------------------------------------------------------------------- /scripts/SystemTap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Installation/customization of system taps scripts 2 | if(USE_SYSTEMTAP) 3 | # system Tap fails with OpenCV (no idea why) 4 | if(USE_OPENCV) 5 | message(FATAL "SystemTap is not working when OpenCV is supported!") 6 | endif() 7 | 8 | # Copy profile.stp and put absolute path to binary and nn lib 9 | file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/profile_selected_function.stp DESTINATION ${CMAKE_BINARY_DIR}) 10 | file(READ ${CMAKE_BINARY_DIR}/profile_selected_function.stp PROFILE_STP_STRING) 11 | string(REPLACE "[DIRNAME_OF_CAFFE_TOOL_BINARY]" "\"${CMAKE_BINARY_DIR}/tools/caffe\"" PROFILE_STP_STRING ${PROFILE_STP_STRING}) 12 | string(REPLACE "[DIRNAME_OF_LIBCAFFE]" "\"${CMAKE_BINARY_DIR}/lib/libcaffe.so\"" PROFILE_STP_STRING ${PROFILE_STP_STRING}) 13 | file(WRITE ${CMAKE_BINARY_DIR}/profile_selected_function.stp ${PROFILE_STP_STRING}) 14 | endif() 15 | -------------------------------------------------------------------------------- /scripts/SystemTap/profile_selected_function.stp: -------------------------------------------------------------------------------- 1 | #Example of running: 2 | #stap /scripts/profile.stp -v --dyninst -c /tools/caffe | c++filt 3 | 4 | global timings_start # Giving size of array here will cause error if size is exceeded , but allow avoid realocation of arrays 5 | global timings 6 | global counts 7 | global histo 8 | 9 | global final_results # Container to combine data from many threads 10 | 11 | ##@define function_name %( "*sync*" %) # Handy macro to define name of functions to be traced 12 | # 13 | @define make_entry_and_exit_probe(process_name,func_name) %( 14 | 15 | probe process(@process_name).function(@func_name).call 16 | { 17 | timings_start[ppfunc(),tid()] = gettimeofday_us() 18 | counts[ppfunc()] <<< 1 19 | } 20 | 21 | probe process(@process_name).function(@func_name).return 22 | { 23 | timings[ppfunc(),tid()] += gettimeofday_us() - timings_start[ppfunc(),tid()]; 24 | histo[ppfunc()] <<< gettimeofday_us() - timings_start[ppfunc(),tid()]; 25 | } 26 | 27 | %) 28 | 29 | # For Caffe C++ we need mangled names put here (can use wildcards "*" for rescue) 30 | @make_entry_and_exit_probe([DIRNAME_OF_CAFFE_TOOL_BINARY],"_Z4timev") 31 | 32 | # Tracing functions of shared lib, example of using wildcards for names of functions 33 | @make_entry_and_exit_probe([DIRNAME_OF_LIBCAFFE],"*caffe_set*") # caffe_set 34 | 35 | probe end 36 | { 37 | # Get per thread results and put them in final container 38 | foreach([x,tid] in timings) 39 | { 40 | final_results[x] += timings[x,tid] 41 | } 42 | 43 | # Presents results 44 | printf("\n\nInclusive profiling results:\n") 45 | foreach([x] in final_results-) { printf("%s, count: %d total time: %d us\n",x,@count(counts[x]),final_results[x])} 46 | 47 | foreach([x] in histo-) 48 | { 49 | printf("Histogram of func: %s:\n",[x]); 50 | print(@hist_log(histo[x])) 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/caffe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # generate protobuf sources 2 | file(GLOB proto_files proto/*.proto) 3 | caffe_protobuf_generate_cpp_py(${proto_gen_folder} proto_srcs proto_hdrs proto_python ${proto_files}) 4 | 5 | # include python files either to force generation 6 | add_library(proto STATIC ${proto_hdrs} ${proto_srcs} ${proto_python}) 7 | set(Caffe_LINKER_LIBS proto ${Caffe_LINKER_LIBS}) # note, crucial to prepend! 8 | caffe_default_properties(proto) 9 | 10 | # --[ Caffe library 11 | 12 | # creates 'test_srcs', 'srcs', 'test_cuda', 'cuda' lists 13 | caffe_pickup_caffe_sources(${PROJECT_SOURCE_DIR}) 14 | 15 | if(HAVE_CUDA) 16 | caffe_cuda_compile(cuda_objs ${cuda}) 17 | list(APPEND srcs ${cuda_objs} ${cuda}) 18 | endif() 19 | 20 | add_library(caffe ${srcs}) 21 | # Add dependency to force building MKLDNN when not given by ENV var 22 | if(NOT DEFINED ENV{MKLDNNROOT}) 23 | add_dependencies(caffe mkldnn) 24 | endif() 25 | target_link_libraries(caffe proto ${Caffe_LINKER_LIBS}) 26 | caffe_default_properties(caffe) 27 | set_target_properties(caffe PROPERTIES 28 | VERSION ${CAFFE_TARGET_VERSION} 29 | SOVERSION ${CAFFE_TARGET_SOVERSION} 30 | ) 31 | 32 | # ---[ Tests 33 | add_subdirectory(test) 34 | 35 | # ---[ Install 36 | install(DIRECTORY ${Caffe_INCLUDE_DIR}/caffe DESTINATION include) 37 | install(FILES ${proto_hdrs} DESTINATION include/caffe/proto) 38 | install(TARGETS caffe proto EXPORT CaffeTargets DESTINATION lib) 39 | 40 | file(WRITE ${PROJECT_BINARY_DIR}/__init__.py) 41 | list(APPEND proto_python ${PROJECT_BINARY_DIR}/__init__.py) 42 | install(PROGRAMS ${proto_python} DESTINATION python/caffe/proto) 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/caffe/layers/absval_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/absval_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void AbsValLayer::Forward_gpu( 10 | const vector*>& bottom, const vector*>& top) { 11 | const int count = top[0]->count(); 12 | Dtype* top_data = top[0]->mutable_gpu_data(); 13 | caffe_gpu_abs(count, bottom[0]->gpu_data(), top_data); 14 | } 15 | 16 | template 17 | void AbsValLayer::Backward_gpu(const vector*>& top, 18 | const vector& propagate_down, const vector*>& bottom) { 19 | const int count = top[0]->count(); 20 | const Dtype* top_diff = top[0]->gpu_diff(); 21 | if (propagate_down[0]) { 22 | const Dtype* bottom_data = bottom[0]->gpu_data(); 23 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 24 | caffe_gpu_sign(count, bottom_data, bottom_diff); 25 | caffe_gpu_mul(count, bottom_diff, top_diff, bottom_diff); 26 | } 27 | } 28 | 29 | INSTANTIATE_LAYER_GPU_FUNCS(AbsValLayer); 30 | 31 | 32 | } // namespace caffe 33 | -------------------------------------------------------------------------------- /src/caffe/layers/base_data_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/base_data_layer.hpp" 4 | 5 | namespace caffe { 6 | 7 | template 8 | void BasePrefetchingDataLayer::Forward_gpu( 9 | const vector*>& bottom, const vector*>& top) { 10 | Batch* batch = prefetch_full_.pop("Data layer prefetch queue empty"); 11 | // Reshape to loaded data. 12 | top[0]->ReshapeLike(batch->data_); 13 | // Copy the data 14 | caffe_copy(batch->data_.count(), batch->data_.gpu_data(), 15 | top[0]->mutable_gpu_data()); 16 | if (this->output_labels_) { 17 | // Reshape to loaded labels. 18 | top[1]->ReshapeLike(batch->label_); 19 | // Copy the labels. 20 | caffe_copy(batch->label_.count(), batch->label_.gpu_data(), 21 | top[1]->mutable_gpu_data()); 22 | } 23 | // Ensure the copy is synchronous wrt the host, so that the next batch isn't 24 | // copied in meanwhile. 25 | CUDA_CHECK(cudaStreamSynchronize(cudaStreamDefault)); 26 | prefetch_free_.push(batch); 27 | } 28 | 29 | INSTANTIATE_LAYER_GPU_FORWARD(BasePrefetchingDataLayer); 30 | 31 | } // namespace caffe 32 | -------------------------------------------------------------------------------- /src/caffe/layers/bnll_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "caffe/layers/bnll_layer.hpp" 5 | 6 | namespace caffe { 7 | 8 | const float kBNLL_THRESHOLD = 50.; 9 | 10 | template 11 | __global__ void BNLLForward(const int n, const Dtype* in, Dtype* out) { 12 | CUDA_KERNEL_LOOP(index, n) { 13 | out[index] = in[index] > 0 ? 14 | in[index] + log(1. + exp(-in[index])) : 15 | log(1. + exp(in[index])); 16 | } 17 | } 18 | 19 | template 20 | void BNLLLayer::Forward_gpu(const vector*>& bottom, 21 | const vector*>& top) { 22 | const Dtype* bottom_data = bottom[0]->gpu_data(); 23 | Dtype* top_data = top[0]->mutable_gpu_data(); 24 | const int count = bottom[0]->count(); 25 | // NOLINT_NEXT_LINE(whitespace/operators) 26 | BNLLForward<<>>( 27 | count, bottom_data, top_data); 28 | CUDA_POST_KERNEL_CHECK; 29 | } 30 | 31 | template 32 | __global__ void BNLLBackward(const int n, const Dtype* in_diff, 33 | const Dtype* in_data, Dtype* out_diff) { 34 | CUDA_KERNEL_LOOP(index, n) { 35 | Dtype expval = exp(min(in_data[index], Dtype(kBNLL_THRESHOLD))); 36 | out_diff[index] = in_diff[index] * expval / (expval + 1.); 37 | } 38 | } 39 | 40 | template 41 | void BNLLLayer::Backward_gpu(const vector*>& top, 42 | const vector& propagate_down, 43 | const vector*>& bottom) { 44 | if (propagate_down[0]) { 45 | const Dtype* bottom_data = bottom[0]->gpu_data(); 46 | const Dtype* top_diff = top[0]->gpu_diff(); 47 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 48 | const int count = bottom[0]->count(); 49 | // NOLINT_NEXT_LINE(whitespace/operators) 50 | BNLLBackward<<>>( 51 | count, top_diff, bottom_data, bottom_diff); 52 | CUDA_POST_KERNEL_CHECK; 53 | } 54 | } 55 | 56 | INSTANTIATE_LAYER_GPU_FUNCS(BNLLLayer); 57 | 58 | 59 | } // namespace caffe 60 | -------------------------------------------------------------------------------- /src/caffe/layers/cudnn_lcn_layer.cu: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUDNN 2 | #include 3 | 4 | #include "caffe/layers/cudnn_lcn_layer.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void CuDNNLCNLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | const Dtype* bottom_data = bottom[0]->gpu_data(); 12 | Dtype* top_data = top[0]->mutable_gpu_data(); 13 | 14 | CUDNN_CHECK(cudnnDivisiveNormalizationForward( 15 | handle_, norm_desc_, CUDNN_DIVNORM_PRECOMPUTED_MEANS, 16 | cudnn::dataType::one, 17 | bottom_desc_, bottom_data, 18 | NULL, // srcMeansData 19 | this->tempData1, this->tempData2, 20 | cudnn::dataType::zero, 21 | top_desc_, top_data) ); 22 | } 23 | 24 | template 25 | void CuDNNLCNLayer::Backward_gpu(const vector*>& top, 26 | const vector& propagate_down, const vector*>& bottom) { 27 | const Dtype* top_diff = top[0]->gpu_diff(); 28 | const Dtype* top_data = top[0]->gpu_data(); 29 | const Dtype* bottom_data = bottom[0]->gpu_data(); 30 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 31 | 32 | CUDNN_CHECK(cudnnDivisiveNormalizationBackward( 33 | handle_, norm_desc_, CUDNN_DIVNORM_PRECOMPUTED_MEANS, 34 | cudnn::dataType::one, 35 | bottom_desc_, bottom_data, 36 | NULL, top_diff, // NULL - srcMeansData 37 | this->tempData1, this->tempData2, 38 | cudnn::dataType::zero, 39 | bottom_desc_, bottom_diff, 40 | NULL) ); 41 | } 42 | 43 | INSTANTIATE_LAYER_GPU_FUNCS(CuDNNLCNLayer); 44 | 45 | } // namespace caffe 46 | #endif 47 | -------------------------------------------------------------------------------- /src/caffe/layers/cudnn_lrn_layer.cu: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUDNN 2 | #include 3 | 4 | #include "caffe/layers/cudnn_lrn_layer.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void CuDNNLRNLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | const Dtype* bottom_data = bottom[0]->gpu_data(); 12 | Dtype* top_data = top[0]->mutable_gpu_data(); 13 | 14 | CUDNN_CHECK(cudnnLRNCrossChannelForward( 15 | handle_, norm_desc_, CUDNN_LRN_CROSS_CHANNEL_DIM1, 16 | cudnn::dataType::one, 17 | bottom_desc_, bottom_data, 18 | cudnn::dataType::zero, 19 | top_desc_, top_data) ); 20 | } 21 | 22 | template 23 | void CuDNNLRNLayer::Backward_gpu(const vector*>& top, 24 | const vector& propagate_down, const vector*>& bottom) { 25 | const Dtype* top_diff = top[0]->gpu_diff(); 26 | const Dtype* top_data = top[0]->gpu_data(); 27 | const Dtype* bottom_data = bottom[0]->gpu_data(); 28 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 29 | 30 | CUDNN_CHECK(cudnnLRNCrossChannelBackward( 31 | handle_, norm_desc_, CUDNN_LRN_CROSS_CHANNEL_DIM1, 32 | cudnn::dataType::one, 33 | top_desc_, top_data, 34 | top_desc_, top_diff, 35 | bottom_desc_, bottom_data, 36 | cudnn::dataType::zero, 37 | bottom_desc_, bottom_diff) ); 38 | } 39 | 40 | INSTANTIATE_LAYER_GPU_FUNCS(CuDNNLRNLayer); 41 | 42 | }; // namespace caffe 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/caffe/layers/cudnn_pooling_layer.cu: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUDNN 2 | #include 3 | 4 | #include "caffe/layers/cudnn_pooling_layer.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void CuDNNPoolingLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | const Dtype* bottom_data = bottom[0]->gpu_data(); 12 | Dtype* top_data = top[0]->mutable_gpu_data(); 13 | CUDNN_CHECK(cudnnPoolingForward(handle_, pooling_desc_, 14 | cudnn::dataType::one, 15 | bottom_desc_, bottom_data, 16 | cudnn::dataType::zero, 17 | top_desc_, top_data)); 18 | } 19 | 20 | template 21 | void CuDNNPoolingLayer::Backward_gpu(const vector*>& top, 22 | const vector& propagate_down, const vector*>& bottom) { 23 | if (!propagate_down[0]) { 24 | return; 25 | } 26 | const Dtype* top_diff = top[0]->gpu_diff(); 27 | const Dtype* top_data = top[0]->gpu_data(); 28 | const Dtype* bottom_data = bottom[0]->gpu_data(); 29 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 30 | CUDNN_CHECK(cudnnPoolingBackward(handle_, pooling_desc_, 31 | cudnn::dataType::one, 32 | top_desc_, top_data, top_desc_, top_diff, 33 | bottom_desc_, bottom_data, 34 | cudnn::dataType::zero, 35 | bottom_desc_, bottom_diff)); 36 | } 37 | 38 | INSTANTIATE_LAYER_GPU_FUNCS(CuDNNPoolingLayer); 39 | 40 | } // namespace caffe 41 | #endif 42 | -------------------------------------------------------------------------------- /src/caffe/layers/cudnn_softmax_layer.cu: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUDNN 2 | #include 3 | 4 | #include "thrust/device_vector.h" 5 | 6 | #include "caffe/layers/cudnn_softmax_layer.hpp" 7 | 8 | namespace caffe { 9 | 10 | template 11 | void CuDNNSoftmaxLayer::Forward_gpu(const vector*>& bottom, 12 | const vector*>& top) { 13 | const Dtype* bottom_data = bottom[0]->gpu_data(); 14 | Dtype* top_data = top[0]->mutable_gpu_data(); 15 | CUDNN_CHECK(cudnnSoftmaxForward(handle_, CUDNN_SOFTMAX_ACCURATE, 16 | CUDNN_SOFTMAX_MODE_CHANNEL, 17 | cudnn::dataType::one, 18 | bottom_desc_, bottom_data, 19 | cudnn::dataType::zero, 20 | top_desc_, top_data)); 21 | } 22 | 23 | template 24 | void CuDNNSoftmaxLayer::Backward_gpu(const vector*>& top, 25 | const vector& propagate_down, const vector*>& bottom) { 26 | if (propagate_down[0]) { 27 | const Dtype* top_data = top[0]->gpu_data(); 28 | const Dtype* top_diff = top[0]->gpu_diff(); 29 | const Dtype* bottom_data = bottom[0]->gpu_data(); 30 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 31 | 32 | CUDNN_CHECK(cudnnSoftmaxBackward(handle_, CUDNN_SOFTMAX_ACCURATE, 33 | CUDNN_SOFTMAX_MODE_CHANNEL, 34 | cudnn::dataType::one, 35 | top_desc_, top_data, top_desc_, top_diff, 36 | cudnn::dataType::zero, 37 | bottom_desc_, bottom_diff)); 38 | } 39 | } 40 | 41 | INSTANTIATE_LAYER_GPU_FUNCS(CuDNNSoftmaxLayer); 42 | 43 | } // namespace caffe 44 | #endif 45 | -------------------------------------------------------------------------------- /src/caffe/layers/euclidean_loss_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/euclidean_loss_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void EuclideanLossLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | int count = bottom[0]->count(); 12 | caffe_gpu_sub( 13 | count, 14 | bottom[0]->gpu_data(), 15 | bottom[1]->gpu_data(), 16 | diff_.mutable_gpu_data()); 17 | Dtype dot; 18 | caffe_gpu_dot(count, diff_.gpu_data(), diff_.gpu_data(), &dot); 19 | Dtype loss = dot / bottom[0]->num() / Dtype(2); 20 | top[0]->mutable_cpu_data()[0] = loss; 21 | } 22 | 23 | template 24 | void EuclideanLossLayer::Backward_gpu(const vector*>& top, 25 | const vector& propagate_down, const vector*>& bottom) { 26 | for (int i = 0; i < 2; ++i) { 27 | if (propagate_down[i]) { 28 | const Dtype sign = (i == 0) ? 1 : -1; 29 | const Dtype alpha = sign * top[0]->cpu_diff()[0] / bottom[i]->num(); 30 | caffe_gpu_axpby( 31 | bottom[i]->count(), // count 32 | alpha, // alpha 33 | diff_.gpu_data(), // a 34 | Dtype(0), // beta 35 | bottom[i]->mutable_gpu_diff()); // b 36 | } 37 | } 38 | } 39 | 40 | INSTANTIATE_LAYER_GPU_FUNCS(EuclideanLossLayer); 41 | 42 | } // namespace caffe 43 | -------------------------------------------------------------------------------- /src/caffe/layers/exp_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/exp_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void ExpLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | const int count = bottom[0]->count(); 12 | const Dtype* bottom_data = bottom[0]->gpu_data(); 13 | Dtype* top_data = top[0]->mutable_gpu_data(); 14 | if (inner_scale_ == Dtype(1)) { 15 | caffe_gpu_exp(count, bottom_data, top_data); 16 | } else { 17 | caffe_gpu_scale(count, inner_scale_, bottom_data, top_data); 18 | caffe_gpu_exp(count, top_data, top_data); 19 | } 20 | if (outer_scale_ != Dtype(1)) { 21 | caffe_gpu_scal(count, outer_scale_, top_data); 22 | } 23 | } 24 | 25 | template 26 | void ExpLayer::Backward_gpu(const vector*>& top, 27 | const vector& propagate_down, const vector*>& bottom) { 28 | if (!propagate_down[0]) { return; } 29 | const int count = bottom[0]->count(); 30 | const Dtype* top_data = top[0]->gpu_data(); 31 | const Dtype* top_diff = top[0]->gpu_diff(); 32 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 33 | caffe_gpu_mul(count, top_data, top_diff, bottom_diff); 34 | if (inner_scale_ != Dtype(1)) { 35 | caffe_gpu_scal(count, inner_scale_, bottom_diff); 36 | } 37 | } 38 | 39 | INSTANTIATE_LAYER_GPU_FUNCS(ExpLayer); 40 | 41 | 42 | } // namespace caffe 43 | -------------------------------------------------------------------------------- /src/caffe/layers/hdf5_data_layer.cu: -------------------------------------------------------------------------------- 1 | /* 2 | TODO: 3 | - only load parts of the file, in accordance with a prototxt param "max_mem" 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "hdf5.h" 10 | #include "hdf5_hl.h" 11 | 12 | #include "caffe/layers/hdf5_data_layer.hpp" 13 | 14 | namespace caffe { 15 | 16 | template 17 | void HDF5DataLayer::Forward_gpu(const vector*>& bottom, 18 | const vector*>& top) { 19 | const int batch_size = this->layer_param_.hdf5_data_param().batch_size(); 20 | for (int i = 0; i < batch_size; ++i, ++current_row_) { 21 | if (current_row_ == hdf_blobs_[0]->shape(0)) { 22 | if (num_files_ > 1) { 23 | current_file_ += 1; 24 | if (current_file_ == num_files_) { 25 | current_file_ = 0; 26 | if (this->layer_param_.hdf5_data_param().shuffle()) { 27 | std::random_shuffle(file_permutation_.begin(), 28 | file_permutation_.end()); 29 | } 30 | DLOG(INFO) << "Looping around to first file."; 31 | } 32 | LoadHDF5FileData( 33 | hdf_filenames_[file_permutation_[current_file_]].c_str()); 34 | } 35 | current_row_ = 0; 36 | if (this->layer_param_.hdf5_data_param().shuffle()) 37 | std::random_shuffle(data_permutation_.begin(), data_permutation_.end()); 38 | } 39 | for (int j = 0; j < this->layer_param_.top_size(); ++j) { 40 | int data_dim = top[j]->count() / top[j]->shape(0); 41 | caffe_copy(data_dim, 42 | &hdf_blobs_[j]->cpu_data()[data_permutation_[current_row_] 43 | * data_dim], &top[j]->mutable_gpu_data()[i * data_dim]); 44 | } 45 | } 46 | } 47 | 48 | INSTANTIATE_LAYER_GPU_FUNCS(HDF5DataLayer); 49 | 50 | } // namespace caffe 51 | -------------------------------------------------------------------------------- /src/caffe/layers/hdf5_output_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "hdf5.h" 4 | #include "hdf5_hl.h" 5 | 6 | #include "caffe/layers/hdf5_output_layer.hpp" 7 | 8 | namespace caffe { 9 | 10 | template 11 | void HDF5OutputLayer::Forward_gpu(const vector*>& bottom, 12 | const vector*>& top) { 13 | CHECK_GE(bottom.size(), 2); 14 | CHECK_EQ(bottom[0]->num(), bottom[1]->num()); 15 | data_blob_.Reshape(bottom[0]->num(), bottom[0]->channels(), 16 | bottom[0]->height(), bottom[0]->width()); 17 | label_blob_.Reshape(bottom[1]->num(), bottom[1]->channels(), 18 | bottom[1]->height(), bottom[1]->width()); 19 | const int data_datum_dim = bottom[0]->count() / bottom[0]->num(); 20 | const int label_datum_dim = bottom[1]->count() / bottom[1]->num(); 21 | 22 | for (int i = 0; i < bottom[0]->num(); ++i) { 23 | caffe_copy(data_datum_dim, &bottom[0]->gpu_data()[i * data_datum_dim], 24 | &data_blob_.mutable_cpu_data()[i * data_datum_dim]); 25 | caffe_copy(label_datum_dim, &bottom[1]->gpu_data()[i * label_datum_dim], 26 | &label_blob_.mutable_cpu_data()[i * label_datum_dim]); 27 | } 28 | SaveBlobs(); 29 | } 30 | 31 | template 32 | void HDF5OutputLayer::Backward_gpu(const vector*>& top, 33 | const vector& propagate_down, const vector*>& bottom) { 34 | return; 35 | } 36 | 37 | INSTANTIATE_LAYER_GPU_FUNCS(HDF5OutputLayer); 38 | 39 | } // namespace caffe 40 | -------------------------------------------------------------------------------- /src/caffe/layers/log_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/log_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void LogLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | const int count = bottom[0]->count(); 12 | const Dtype* bottom_data = bottom[0]->gpu_data(); 13 | Dtype* top_data = top[0]->mutable_gpu_data(); 14 | if (input_scale_ == Dtype(1) && input_shift_ == Dtype(0)) { 15 | caffe_gpu_log(count, bottom_data, top_data); 16 | } else { 17 | caffe_copy(count, bottom_data, top_data); 18 | if (input_scale_ != Dtype(1)) { 19 | caffe_gpu_scal(count, input_scale_, top_data); 20 | } 21 | if (input_shift_ != Dtype(0)) { 22 | caffe_gpu_add_scalar(count, input_shift_, top_data); 23 | } 24 | caffe_gpu_log(count, top_data, top_data); 25 | } 26 | if (base_scale_ != Dtype(1)) { 27 | caffe_gpu_scal(count, base_scale_, top_data); 28 | } 29 | } 30 | 31 | template 32 | void LogLayer::Backward_gpu(const vector*>& top, 33 | const vector& propagate_down, const vector*>& bottom) { 34 | if (!propagate_down[0]) { return; } 35 | const int count = bottom[0]->count(); 36 | const Dtype* bottom_data = bottom[0]->gpu_data(); 37 | const Dtype* top_diff = top[0]->gpu_diff(); 38 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 39 | caffe_copy(count, bottom_data, bottom_diff); 40 | if (input_scale_ != Dtype(1)) { 41 | caffe_gpu_scal(count, input_scale_, bottom_diff); 42 | } 43 | if (input_shift_ != Dtype(0)) { 44 | caffe_gpu_add_scalar(count, input_shift_, bottom_diff); 45 | } 46 | caffe_gpu_powx(count, bottom_diff, Dtype(-1), bottom_diff); 47 | if (backward_num_scale_ != Dtype(1)) { 48 | caffe_gpu_scal(count, backward_num_scale_, bottom_diff); 49 | } 50 | caffe_gpu_mul(count, top_diff, bottom_diff, bottom_diff); 51 | } 52 | 53 | INSTANTIATE_LAYER_GPU_FUNCS(LogLayer); 54 | 55 | } // namespace caffe 56 | -------------------------------------------------------------------------------- /src/caffe/layers/parameter_layer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | All modification made by Intel Corporation: © 2016 Intel Corporation 3 | 4 | All contributions by the University of California: 5 | Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | All rights reserved. 7 | 8 | All other contributions: 9 | Copyright (c) 2014, 2015, the respective contributors 10 | All rights reserved. 11 | For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | * Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | * Neither the name of Intel Corporation nor the names of its contributors 23 | may be used to endorse or promote products derived from this software 24 | without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | #include "caffe/layers/parameter_layer.hpp" 39 | 40 | namespace caffe { 41 | 42 | INSTANTIATE_CLASS(ParameterLayer); 43 | REGISTER_LAYER_CLASS(Parameter); 44 | 45 | } // namespace caffe 46 | -------------------------------------------------------------------------------- /src/caffe/layers/recurrent_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/blob.hpp" 4 | #include "caffe/common.hpp" 5 | #include "caffe/filler.hpp" 6 | #include "caffe/layer.hpp" 7 | #include "caffe/layers/recurrent_layer.hpp" 8 | #include "caffe/util/math_functions.hpp" 9 | 10 | namespace caffe { 11 | 12 | template 13 | void RecurrentLayer::Forward_gpu(const vector*>& bottom, 14 | const vector*>& top) { 15 | // Hacky fix for test time... reshare all the shared blobs. 16 | // TODO: somehow make this work non-hackily. 17 | if (this->phase_ == TEST) { 18 | unrolled_net_->ShareWeights(); 19 | } 20 | 21 | DCHECK_EQ(recur_input_blobs_.size(), recur_output_blobs_.size()); 22 | if (!expose_hidden_) { 23 | for (int i = 0; i < recur_input_blobs_.size(); ++i) { 24 | const int count = recur_input_blobs_[i]->count(); 25 | DCHECK_EQ(count, recur_output_blobs_[i]->count()); 26 | const Dtype* timestep_T_data = recur_output_blobs_[i]->gpu_data(); 27 | Dtype* timestep_0_data = recur_input_blobs_[i]->mutable_gpu_data(); 28 | caffe_copy(count, timestep_T_data, timestep_0_data); 29 | } 30 | } 31 | 32 | unrolled_net_->ForwardTo(last_layer_index_); 33 | 34 | if (expose_hidden_) { 35 | const int top_offset = output_blobs_.size(); 36 | for (int i = top_offset, j = 0; i < top.size(); ++i, ++j) { 37 | top[i]->ShareData(*recur_output_blobs_[j]); 38 | } 39 | } 40 | } 41 | 42 | INSTANTIATE_LAYER_GPU_FORWARD(RecurrentLayer); 43 | 44 | } // namespace caffe 45 | -------------------------------------------------------------------------------- /src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/sigmoid_cross_entropy_loss_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void SigmoidCrossEntropyLossLayer::Backward_gpu( 10 | const vector*>& top, const vector& propagate_down, 11 | const vector*>& bottom) { 12 | if (propagate_down[1]) { 13 | LOG(FATAL) << this->type() 14 | << " Layer cannot backpropagate to label inputs."; 15 | } 16 | if (propagate_down[0]) { 17 | // First, compute the diff 18 | const int count = bottom[0]->count(); 19 | const int num = bottom[0]->num(); 20 | const Dtype* sigmoid_output_data = sigmoid_output_->gpu_data(); 21 | const Dtype* target = bottom[1]->gpu_data(); 22 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 23 | caffe_copy(count, sigmoid_output_data, bottom_diff); 24 | caffe_gpu_axpy(count, Dtype(-1), target, bottom_diff); 25 | // Scale down gradient 26 | const Dtype loss_weight = top[0]->cpu_diff()[0]; 27 | caffe_gpu_scal(count, loss_weight / num, bottom_diff); 28 | } 29 | } 30 | 31 | INSTANTIATE_LAYER_GPU_BACKWARD(SigmoidCrossEntropyLossLayer); 32 | 33 | 34 | } // namespace caffe 35 | -------------------------------------------------------------------------------- /src/caffe/layers/sigmoid_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "caffe/layers/sigmoid_layer.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | __global__ void SigmoidForward(const int n, const Dtype* in, Dtype* out) { 10 | CUDA_KERNEL_LOOP(index, n) { 11 | out[index] = 1. / (1. + exp(-in[index])); 12 | } 13 | } 14 | 15 | template 16 | void SigmoidLayer::Forward_gpu(const vector*>& bottom, 17 | const vector*>& top) { 18 | const Dtype* bottom_data = bottom[0]->gpu_data(); 19 | Dtype* top_data = top[0]->mutable_gpu_data(); 20 | const int count = bottom[0]->count(); 21 | // NOLINT_NEXT_LINE(whitespace/operators) 22 | SigmoidForward<<>>( 23 | count, bottom_data, top_data); 24 | CUDA_POST_KERNEL_CHECK; 25 | // << " count: " << count << " bottom_data: " 26 | // << (unsigned long)bottom_data 27 | // << " top_data: " << (unsigned long)top_data 28 | // << " blocks: " << CAFFE_GET_BLOCKS(count) 29 | // << " threads: " << CAFFE_CUDA_NUM_THREADS; 30 | } 31 | 32 | template 33 | __global__ void SigmoidBackward(const int n, const Dtype* in_diff, 34 | const Dtype* out_data, Dtype* out_diff) { 35 | CUDA_KERNEL_LOOP(index, n) { 36 | const Dtype sigmoid_x = out_data[index]; 37 | out_diff[index] = in_diff[index] * sigmoid_x * (1 - sigmoid_x); 38 | } 39 | } 40 | 41 | template 42 | void SigmoidLayer::Backward_gpu(const vector*>& top, 43 | const vector& propagate_down, 44 | const vector*>& bottom) { 45 | if (propagate_down[0]) { 46 | const Dtype* top_data = top[0]->gpu_data(); 47 | const Dtype* top_diff = top[0]->gpu_diff(); 48 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 49 | const int count = bottom[0]->count(); 50 | // NOLINT_NEXT_LINE(whitespace/operators) 51 | SigmoidBackward<<>>( 52 | count, top_diff, top_data, bottom_diff); 53 | CUDA_POST_KERNEL_CHECK; 54 | } 55 | } 56 | 57 | INSTANTIATE_LAYER_GPU_FUNCS(SigmoidLayer); 58 | 59 | 60 | } // namespace caffe 61 | -------------------------------------------------------------------------------- /src/caffe/layers/silence_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/silence_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void SilenceLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | // Do nothing. 12 | } 13 | 14 | template 15 | void SilenceLayer::Backward_gpu(const vector*>& top, 16 | const vector& propagate_down, const vector*>& bottom) { 17 | for (int i = 0; i < bottom.size(); ++i) { 18 | if (propagate_down[i]) { 19 | caffe_gpu_set(bottom[i]->count(), Dtype(0), 20 | bottom[i]->mutable_gpu_diff()); 21 | } 22 | } 23 | } 24 | 25 | INSTANTIATE_LAYER_GPU_FUNCS(SilenceLayer); 26 | 27 | } // namespace caffe 28 | -------------------------------------------------------------------------------- /src/caffe/layers/split_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/split_layer.hpp" 4 | #include "caffe/util/math_functions.hpp" 5 | 6 | namespace caffe { 7 | 8 | template 9 | void SplitLayer::Forward_gpu(const vector*>& bottom, 10 | const vector*>& top) { 11 | for (int i = 0; i < top.size(); ++i) { 12 | top[i]->ShareData(*bottom[0]); 13 | } 14 | } 15 | 16 | template 17 | void SplitLayer::Backward_gpu(const vector*>& top, 18 | const vector& propagate_down, const vector*>& bottom) { 19 | if (!propagate_down[0]) { return; } 20 | if (top.size() == 1) { 21 | caffe_copy(count_, top[0]->gpu_diff(), bottom[0]->mutable_gpu_diff()); 22 | return; 23 | } 24 | caffe_gpu_add(count_, top[0]->gpu_diff(), top[1]->gpu_diff(), 25 | bottom[0]->mutable_gpu_diff()); 26 | // Add remaining top blob diffs. 27 | for (int i = 2; i < top.size(); ++i) { 28 | const Dtype* top_diff = top[i]->gpu_diff(); 29 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 30 | caffe_gpu_axpy(count_, Dtype(1.), top_diff, bottom_diff); 31 | } 32 | } 33 | 34 | 35 | INSTANTIATE_LAYER_GPU_FUNCS(SplitLayer); 36 | 37 | } // namespace caffe 38 | -------------------------------------------------------------------------------- /src/caffe/layers/tanh_layer.cu: -------------------------------------------------------------------------------- 1 | // TanH neuron activation function layer. 2 | // Adapted from ReLU layer code written by Yangqing Jia 3 | 4 | #include 5 | 6 | #include "caffe/layers/tanh_layer.hpp" 7 | 8 | namespace caffe { 9 | 10 | template 11 | __global__ void TanHForward(const int n, const Dtype* in, Dtype* out) { 12 | CUDA_KERNEL_LOOP(index, n) { 13 | out[index] = tanh(in[index]); 14 | } 15 | } 16 | 17 | template 18 | void TanHLayer::Forward_gpu(const vector*>& bottom, 19 | const vector*>& top) { 20 | const Dtype* bottom_data = bottom[0]->gpu_data(); 21 | Dtype* top_data = top[0]->mutable_gpu_data(); 22 | const int count = bottom[0]->count(); 23 | // NOLINT_NEXT_LINE(whitespace/operators) 24 | TanHForward<<>>( 25 | count, bottom_data, top_data); 26 | CUDA_POST_KERNEL_CHECK; 27 | } 28 | 29 | template 30 | __global__ void TanHBackward(const int n, const Dtype* in_diff, 31 | const Dtype* out_data, Dtype* out_diff) { 32 | CUDA_KERNEL_LOOP(index, n) { 33 | Dtype tanhx = out_data[index]; 34 | out_diff[index] = in_diff[index] * (1 - tanhx * tanhx); 35 | } 36 | } 37 | 38 | template 39 | void TanHLayer::Backward_gpu(const vector*>& top, 40 | const vector& propagate_down, 41 | const vector*>& bottom) { 42 | if (propagate_down[0]) { 43 | const Dtype* top_data = top[0]->gpu_data(); 44 | const Dtype* top_diff = top[0]->gpu_diff(); 45 | Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); 46 | const int count = bottom[0]->count(); 47 | // NOLINT_NEXT_LINE(whitespace/operators) 48 | TanHBackward<<>>( 49 | count, top_diff, top_data, bottom_diff); 50 | CUDA_POST_KERNEL_CHECK; 51 | } 52 | } 53 | 54 | INSTANTIATE_LAYER_GPU_FUNCS(TanHLayer); 55 | 56 | 57 | } // namespace caffe 58 | -------------------------------------------------------------------------------- /src/caffe/layers/threshold_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/threshold_layer.hpp" 4 | 5 | namespace caffe { 6 | 7 | template 8 | __global__ void ThresholdForward(const int n, const Dtype threshold, 9 | const Dtype* in, Dtype* out) { 10 | CUDA_KERNEL_LOOP(index, n) { 11 | out[index] = in[index] > threshold ? 1 : 0; 12 | } 13 | } 14 | 15 | template 16 | void ThresholdLayer::Forward_gpu(const vector*>& bottom, 17 | const vector*>& top) { 18 | const Dtype* bottom_data = bottom[0]->gpu_data(); 19 | Dtype* top_data = top[0]->mutable_gpu_data(); 20 | const int count = bottom[0]->count(); 21 | // NOLINT_NEXT_LINE(whitespace/operators) 22 | ThresholdForward<<>>( 23 | count, threshold_, bottom_data, top_data); 24 | CUDA_POST_KERNEL_CHECK; 25 | } 26 | 27 | 28 | INSTANTIATE_LAYER_GPU_FORWARD(ThresholdLayer); 29 | 30 | 31 | } // namespace caffe 32 | -------------------------------------------------------------------------------- /src/caffe/solvers/adadelta_solver.cu: -------------------------------------------------------------------------------- 1 | #include "caffe/util/math_functions.hpp" 2 | 3 | 4 | namespace caffe { 5 | 6 | template 7 | __global__ void AdaDeltaUpdate(int N, Dtype* g, Dtype* h, Dtype* h2, 8 | Dtype momentum, Dtype delta, Dtype local_rate) { 9 | CUDA_KERNEL_LOOP(i, N) { 10 | float gi = g[i]; 11 | float hi = h[i] = momentum * h[i] + (1-momentum) * gi * gi; 12 | gi = gi * sqrt((h2[i] + delta) / (hi + delta)); 13 | h2[i] = momentum * h2[i] + (1-momentum) * gi * gi; 14 | g[i] = local_rate * gi; 15 | } 16 | } 17 | template 18 | void adadelta_update_gpu(int N, Dtype* g, Dtype* h, Dtype* h2, Dtype momentum, 19 | Dtype delta, Dtype local_rate) { 20 | AdaDeltaUpdate // NOLINT_NEXT_LINE(whitespace/operators) 21 | <<>>( 22 | N, g, h, h2, momentum, delta, local_rate); 23 | CUDA_POST_KERNEL_CHECK; 24 | } 25 | template void adadelta_update_gpu(int , float*, float*, float*, 26 | float, float, float); 27 | template void adadelta_update_gpu(int, double*, double*, double*, 28 | double, double, double); 29 | 30 | } // namespace caffe 31 | -------------------------------------------------------------------------------- /src/caffe/solvers/adagrad_solver.cu: -------------------------------------------------------------------------------- 1 | #include "caffe/util/math_functions.hpp" 2 | 3 | 4 | namespace caffe { 5 | 6 | template 7 | __global__ void AdaGradUpdate(int N, Dtype* g, Dtype* h, Dtype delta, 8 | Dtype local_rate) { 9 | CUDA_KERNEL_LOOP(i, N) { 10 | float gi = g[i]; 11 | float hi = h[i] = h[i] + gi*gi; 12 | g[i] = local_rate * gi / (sqrt(hi) + delta); 13 | } 14 | } 15 | template 16 | void adagrad_update_gpu(int N, Dtype* g, Dtype* h, Dtype delta, 17 | Dtype local_rate) { 18 | AdaGradUpdate // NOLINT_NEXT_LINE(whitespace/operators) 19 | <<>>( 20 | N, g, h, delta, local_rate); 21 | CUDA_POST_KERNEL_CHECK; 22 | } 23 | template void adagrad_update_gpu(int, float*, float*, float, float); 24 | template void adagrad_update_gpu(int, double*, double*, double, double); 25 | 26 | } // namespace caffe 27 | -------------------------------------------------------------------------------- /src/caffe/solvers/adam_solver.cu: -------------------------------------------------------------------------------- 1 | #include "caffe/util/math_functions.hpp" 2 | 3 | 4 | namespace caffe { 5 | 6 | template 7 | __global__ void AdamUpdate(int N, Dtype* g, Dtype* m, Dtype* v, 8 | Dtype beta1, Dtype beta2, Dtype eps_hat, Dtype corrected_local_rate) { 9 | CUDA_KERNEL_LOOP(i, N) { 10 | float gi = g[i]; 11 | float mi = m[i] = m[i]*beta1 + gi*(1-beta1); 12 | float vi = v[i] = v[i]*beta2 + gi*gi*(1-beta2); 13 | g[i] = corrected_local_rate * mi / (sqrt(vi) + eps_hat); 14 | } 15 | } 16 | template 17 | void adam_update_gpu(int N, Dtype* g, Dtype* m, Dtype* v, Dtype beta1, 18 | Dtype beta2, Dtype eps_hat, Dtype corrected_local_rate) { 19 | AdamUpdate // NOLINT_NEXT_LINE(whitespace/operators) 20 | <<>>( 21 | N, g, m, v, beta1, beta2, eps_hat, corrected_local_rate); 22 | CUDA_POST_KERNEL_CHECK; 23 | } 24 | template void adam_update_gpu(int, float*, float*, float*, 25 | float, float, float, float); 26 | template void adam_update_gpu(int, double*, double*, double*, 27 | double, double, double, double); 28 | 29 | } // namespace caffe 30 | -------------------------------------------------------------------------------- /src/caffe/solvers/nesterov_solver.cu: -------------------------------------------------------------------------------- 1 | #include "caffe/util/math_functions.hpp" 2 | 3 | 4 | namespace caffe { 5 | 6 | template 7 | __global__ void NesterovUpdate(int N, Dtype* g, Dtype* h, 8 | Dtype momentum, Dtype local_rate) { 9 | CUDA_KERNEL_LOOP(i, N) { 10 | float hi = h[i]; 11 | float hi_new = h[i] = momentum * hi + local_rate * g[i]; 12 | g[i] = (1+momentum) * hi_new - momentum * hi; 13 | } 14 | } 15 | template 16 | void nesterov_update_gpu(int N, Dtype* g, Dtype* h, Dtype momentum, 17 | Dtype local_rate) { 18 | NesterovUpdate // NOLINT_NEXT_LINE(whitespace/operators) 19 | <<>>( 20 | N, g, h, momentum, local_rate); 21 | CUDA_POST_KERNEL_CHECK; 22 | } 23 | template void nesterov_update_gpu(int, float*, float*, float, float); 24 | template void nesterov_update_gpu(int, double*, double*, double, 25 | double); 26 | 27 | } // namespace caffe 28 | -------------------------------------------------------------------------------- /src/caffe/solvers/rmsprop_solver.cu: -------------------------------------------------------------------------------- 1 | #include "caffe/util/math_functions.hpp" 2 | 3 | 4 | namespace caffe { 5 | 6 | template 7 | __global__ void RMSPropUpdate(int N, Dtype* g, Dtype* h, 8 | Dtype rms_decay, Dtype delta, Dtype local_rate) { 9 | CUDA_KERNEL_LOOP(i, N) { 10 | float gi = g[i]; 11 | float hi = h[i] = rms_decay*h[i] + (1-rms_decay)*gi*gi; 12 | g[i] = local_rate * g[i] / (sqrt(hi) + delta); 13 | } 14 | } 15 | template 16 | void rmsprop_update_gpu(int N, Dtype* g, Dtype* h, Dtype rms_decay, 17 | Dtype delta, Dtype local_rate) { 18 | RMSPropUpdate // NOLINT_NEXT_LINE(whitespace/operators) 19 | <<>>( 20 | N, g, h, rms_decay, delta, local_rate); 21 | CUDA_POST_KERNEL_CHECK; 22 | } 23 | template void rmsprop_update_gpu(int, float*, float*, float, float, 24 | float); 25 | template void rmsprop_update_gpu(int, double*, double*, double, double, 26 | double); 27 | 28 | } // namespace caffe 29 | -------------------------------------------------------------------------------- /src/caffe/solvers/sgd_solver.cu: -------------------------------------------------------------------------------- 1 | #include "caffe/util/math_functions.hpp" 2 | 3 | 4 | namespace caffe { 5 | 6 | template 7 | __global__ void SGDUpdate(int N, Dtype* g, Dtype* h, 8 | Dtype momentum, Dtype local_rate) { 9 | CUDA_KERNEL_LOOP(i, N) { 10 | g[i] = h[i] = momentum*h[i] + local_rate*g[i]; 11 | } 12 | } 13 | template 14 | void sgd_update_gpu(int N, Dtype* g, Dtype* h, Dtype momentum, 15 | Dtype local_rate) { 16 | SGDUpdate // NOLINT_NEXT_LINE(whitespace/operators) 17 | <<>>( 18 | N, g, h, momentum, local_rate); 19 | CUDA_POST_KERNEL_CHECK; 20 | } 21 | template void sgd_update_gpu(int, float*, float*, float, float); 22 | template void sgd_update_gpu(int, double*, double*, double, double); 23 | 24 | } // namespace caffe 25 | -------------------------------------------------------------------------------- /src/caffe/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The option allows to include in build only selected test files and exclude all others 2 | # Usage example: 3 | # cmake -DBUILD_only_tests="common,net,blob,im2col_kernel" 4 | set(BUILD_only_tests "" CACHE STRING "Blank or comma-separated list of test files to build without 'test_' prefix and extention") 5 | caffe_leave_only_selected_tests(test_srcs ${BUILD_only_tests}) 6 | caffe_leave_only_selected_tests(test_cuda ${BUILD_only_tests}) 7 | 8 | # For 'make runtest' target we don't need to embed test data paths to 9 | # source files, because test target is executed in source directory 10 | # That's why the lines below are commented. TODO: remove them 11 | 12 | # definition needed to include CMake generated files 13 | #add_definitions(-DCMAKE_BUILD) 14 | 15 | # generates test_data/sample_data_list.txt.gen.cmake 16 | #caffe_configure_testdatafile(test_data/sample_data_list.txt) 17 | 18 | set(the_target test.testbin) 19 | set(test_args --gtest_shuffle) 20 | 21 | if(HAVE_CUDA) 22 | caffe_cuda_compile(test_cuda_objs ${test_cuda}) 23 | list(APPEND test_srcs ${test_cuda_objs} ${test_cuda}) 24 | else() 25 | list(APPEND test_args --gtest_filter="-*GPU*") 26 | endif() 27 | 28 | # ---[ Adding test target 29 | add_executable(${the_target} EXCLUDE_FROM_ALL ${test_srcs}) 30 | target_link_libraries(${the_target} gtest gmock ${Caffe_LINK}) 31 | caffe_default_properties(${the_target}) 32 | caffe_set_runtime_directory(${the_target} "${PROJECT_BINARY_DIR}/test") 33 | 34 | # ---[ Adding runtest 35 | add_custom_target(runtest COMMAND ${the_target} ${test_args} 36 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 37 | -------------------------------------------------------------------------------- /src/caffe/test/test_data/sample_data.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/src/caffe/test/test_data/sample_data.h5 -------------------------------------------------------------------------------- /src/caffe/test/test_data/sample_data_2_gzip.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/src/caffe/test/test_data/sample_data_2_gzip.h5 -------------------------------------------------------------------------------- /src/caffe/test/test_data/sample_data_list.txt: -------------------------------------------------------------------------------- 1 | src/caffe/test/test_data/sample_data.h5 2 | src/caffe/test/test_data/sample_data_2_gzip.h5 3 | -------------------------------------------------------------------------------- /src/caffe/test/test_data/solver_data.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NonvolatileMemory/caffe/12df9539ea261c463030820d92b0fbcd144aa4ff/src/caffe/test/test_data/solver_data.h5 -------------------------------------------------------------------------------- /src/caffe/test/test_data/solver_data_list.txt: -------------------------------------------------------------------------------- 1 | src/caffe/test/test_data/solver_data.h5 2 | -------------------------------------------------------------------------------- /src/caffe/test/test_data/test_topology.prototxt: -------------------------------------------------------------------------------- 1 | name: "testNet" 2 | layer { 3 | name: "data" 4 | type: "Data" 5 | top: "data" 6 | top: "label" 7 | include { 8 | phase: TRAIN 9 | } 10 | transform_param { 11 | mirror: true 12 | crop_size: 224 13 | mean_value: 104 14 | mean_value: 117 15 | mean_value: 123 16 | } 17 | data_param { 18 | source: "examples/imagenet/ilsvrc12_train_lmdb" 19 | batch_size: 32 20 | backend: LMDB 21 | } 22 | } 23 | layer { 24 | name: "data" 25 | type: "Data" 26 | top: "data" 27 | top: "label" 28 | include { 29 | phase: TEST 30 | } 31 | transform_param { 32 | mirror: false 33 | crop_size: 224 34 | mean_value: 104 35 | mean_value: 117 36 | mean_value: 123 37 | } 38 | data_param { 39 | source: "examples/imagenet/ilsvrc12_val_lmdb" 40 | batch_size: 50 41 | backend: LMDB 42 | } 43 | } -------------------------------------------------------------------------------- /src/gmock/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Mocking Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Benoit Sigoure 7 | Bogdan Piloca 8 | Chandler Carruth 9 | Dave MacLachlan 10 | David Anderson 11 | Dean Sturtevant 12 | Gene Volovich 13 | Hal Burch 14 | Jeffrey Yasskin 15 | Jim Keller 16 | Joe Walnes 17 | Jon Wray 18 | Keir Mierle 19 | Keith Ray 20 | Kostya Serebryany 21 | Lev Makhlis 22 | Manuel Klimek 23 | Mario Tanev 24 | Mark Paskin 25 | Markus Heule 26 | Matthew Simmons 27 | Mike Bland 28 | Neal Norwitz 29 | Nermin Ozkiranartli 30 | Owen Carlsen 31 | Paneendra Ba 32 | Paul Menage 33 | Piotr Kaminski 34 | Russ Rufer 35 | Sverre Sundsdal 36 | Takeshi Yoshino 37 | Vadim Berman 38 | Vlad Losev 39 | Wolfgang Klier 40 | Zhanyong Wan 41 | -------------------------------------------------------------------------------- /src/gmock/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/gtest/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /src/gtest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Collect source files 2 | file(GLOB_RECURSE srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 3 | 4 | # Build each source file independently 5 | foreach(source ${srcs}) 6 | get_filename_component(name ${source} NAME_WE) 7 | 8 | # caffe target already exits 9 | if(name MATCHES "caffe") 10 | set(name ${name}.bin) 11 | endif() 12 | 13 | # target 14 | add_executable(${name} ${source}) 15 | target_link_libraries(${name} ${Caffe_LINK}) 16 | caffe_default_properties(${name}) 17 | 18 | # set back RUNTIME_OUTPUT_DIRECTORY 19 | caffe_set_runtime_directory(${name} "${PROJECT_BINARY_DIR}/tools") 20 | caffe_set_solution_folder(${name} tools) 21 | 22 | # restore output name without suffix 23 | if(name MATCHES "caffe.bin") 24 | set_target_properties(${name} PROPERTIES OUTPUT_NAME caffe) 25 | endif() 26 | 27 | # Install 28 | install(TARGETS ${name} DESTINATION bin) 29 | endforeach(source) 30 | -------------------------------------------------------------------------------- /tools/device_query.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | All modification made by Intel Corporation: © 2016 Intel Corporation 3 | 4 | All contributions by the University of California: 5 | Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | All rights reserved. 7 | 8 | All other contributions: 9 | Copyright (c) 2014, 2015, the respective contributors 10 | All rights reserved. 11 | For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | * Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | * Neither the name of Intel Corporation nor the names of its contributors 23 | may be used to endorse or promote products derived from this software 24 | without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | #include "caffe/common.hpp" 39 | 40 | int main(int argc, char** argv) { 41 | LOG(FATAL) << "Deprecated. Use caffe device_query " 42 | "[--device_id=0] instead."; 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /tools/test_net.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | All modification made by Intel Corporation: © 2016 Intel Corporation 3 | 4 | All contributions by the University of California: 5 | Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | All rights reserved. 7 | 8 | All other contributions: 9 | Copyright (c) 2014, 2015, the respective contributors 10 | All rights reserved. 11 | For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | * Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | * Neither the name of Intel Corporation nor the names of its contributors 23 | may be used to endorse or promote products derived from this software 24 | without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | #include "caffe/caffe.hpp" 39 | 40 | int main(int argc, char** argv) { 41 | LOG(FATAL) << "Deprecated. Use caffe test --model=... " 42 | "--weights=... instead."; 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /tools/train_net.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | All modification made by Intel Corporation: © 2016 Intel Corporation 3 | 4 | All contributions by the University of California: 5 | Copyright (c) 2014, 2015, The Regents of the University of California (Regents) 6 | All rights reserved. 7 | 8 | All other contributions: 9 | Copyright (c) 2014, 2015, the respective contributors 10 | All rights reserved. 11 | For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md 12 | 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | * Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | * Neither the name of Intel Corporation nor the names of its contributors 23 | may be used to endorse or promote products derived from this software 24 | without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | #include "caffe/caffe.hpp" 39 | 40 | int main(int argc, char** argv) { 41 | LOG(FATAL) << "Deprecated. Use caffe train --solver=... " 42 | "[--snapshot=...] instead."; 43 | return 0; 44 | } 45 | --------------------------------------------------------------------------------