├── apps ├── caffe │ ├── docs │ │ ├── tutorial │ │ │ ├── fig │ │ │ │ ├── .gitignore │ │ │ │ ├── forward.jpg │ │ │ │ ├── layer.jpg │ │ │ │ ├── logreg.jpg │ │ │ │ ├── backward.jpg │ │ │ │ └── forward_backward.png │ │ │ └── convolution.md │ │ ├── CNAME │ │ ├── images │ │ │ ├── caffeine-icon.png │ │ │ └── GitHub-Mark-64px.png │ │ ├── _config.yml │ │ ├── README.md │ │ └── stylesheets │ │ │ └── reset.css │ ├── src │ │ ├── caffe │ │ │ ├── solvers │ │ │ │ ├── sgd_solver.cpp │ │ │ │ ├── sgd_solver.cu │ │ │ │ ├── adagrad_solver.cu │ │ │ │ ├── nesterov_solver.cu │ │ │ │ ├── rmsprop_solver.cu │ │ │ │ ├── adadelta_solver.cu │ │ │ │ └── adam_solver.cu │ │ │ ├── layers │ │ │ │ ├── base_data_layer.c │ │ │ │ ├── neuron_layer.cpp │ │ │ │ ├── silence_layer.cpp │ │ │ │ ├── silence_layer.cu │ │ │ │ ├── loss_layer.cpp │ │ │ │ ├── threshold_layer.cpp │ │ │ │ ├── threshold_layer.cu │ │ │ │ ├── absval_layer.cu │ │ │ │ ├── base_data_layer.cu │ │ │ │ ├── reshape_layer.cu │ │ │ │ ├── recurrent_layer.cu │ │ │ │ └── sigmoid_cross_entropy_loss_layer.cu │ │ │ ├── test │ │ │ │ ├── test_data │ │ │ │ │ ├── solver_data_list.txt │ │ │ │ │ ├── sample_data_list.txt │ │ │ │ │ ├── sample_data.h5 │ │ │ │ │ ├── solver_data.h5 │ │ │ │ │ └── sample_data_2_gzip.h5 │ │ │ │ └── test_protobuf.cpp │ │ │ ├── layer.cpp │ │ │ └── util │ │ │ │ ├── cudnn.cpp │ │ │ │ ├── db_leveldb.cpp │ │ │ │ └── db.cpp │ │ └── gtest │ │ │ └── CMakeLists.txt │ ├── examples │ │ ├── imagenet │ │ │ ├── 1part │ │ │ │ ├── machinefile │ │ │ │ ├── ps_config_caffenet │ │ │ │ ├── ps_config_googlenet │ │ │ │ ├── caffenet_solver.prototxt.template │ │ │ │ ├── inception_solver.prototxt.template │ │ │ │ └── googlenet_solver.prototxt.template │ │ │ ├── 8parts │ │ │ │ ├── machinefile │ │ │ │ ├── ps_config_inception │ │ │ │ ├── ps_config_inception_v3 │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── ps_config_caffenet │ │ │ │ ├── alexnet_solver.prototxt.template │ │ │ │ ├── googlenetv2_solver.prototxt.template │ │ │ │ ├── resnet_50_solver.prototxt.template │ │ │ │ ├── inception_v3_solver.prototxt.template │ │ │ │ ├── inception_solver.prototxt.template │ │ │ │ ├── adam_solver.prototxt.template │ │ │ │ ├── caffenet_solver.prototxt.template │ │ │ │ ├── googlenet_solver.prototxt.template │ │ │ │ ├── ps_config_googlenet │ │ │ │ ├── ps_config_resnet │ │ │ │ ├── ps_config_resnet10 │ │ │ │ ├── ps_config_googlenetv2 │ │ │ │ ├── train_caffenet.sh │ │ │ │ ├── train_inception.sh │ │ │ │ ├── train_inception_v3.sh │ │ │ │ ├── train_resnet.sh │ │ │ │ ├── train_resnet10.sh │ │ │ │ └── train_googlenet.sh │ │ │ ├── 11parts │ │ │ │ ├── ps_config_inception │ │ │ │ ├── ps_config_inception_v3 │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── ps_config_caffenet │ │ │ │ ├── machinefile │ │ │ │ ├── alexnet_solver.prototxt.template │ │ │ │ ├── inception_v3_solver.prototxt.template │ │ │ │ ├── inception_solver.prototxt.template │ │ │ │ ├── ps_config_googlenet │ │ │ │ ├── adam_solver.prototxt.template │ │ │ │ ├── googlenet_solver.prototxt.template │ │ │ │ ├── caffenet_solver.prototxt.template │ │ │ │ ├── train_caffenet.sh │ │ │ │ ├── train_inception.sh │ │ │ │ ├── train_googlenet.sh │ │ │ │ └── train_inception_v3.sh │ │ │ ├── resume_training.sh │ │ │ └── make_imagenet_mean.sh │ │ ├── cifar10 │ │ │ ├── 1parts │ │ │ │ ├── machinefile │ │ │ │ ├── create_cifar10_pdsh.sh │ │ │ │ ├── gnlenet_solver.prototxt.template │ │ │ │ ├── create_cifar10.sh.template │ │ │ │ ├── ps_config_gnlenet │ │ │ │ └── train_gnlenet.sh │ │ │ ├── 2parts │ │ │ │ ├── machinefile │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── create_cifar10_pdsh.sh │ │ │ │ ├── gnlenet_solver.prototxt.template │ │ │ │ ├── bnlenet_solver.prototxt.template │ │ │ │ ├── resnet20_solver.prototxt.template │ │ │ │ ├── alexnet_solver.prototxt.template │ │ │ │ ├── googlenet_solver.prototxt.template │ │ │ │ ├── lenet_solver.prototxt.template │ │ │ │ ├── brnlenet1_solver.prototxt.template │ │ │ │ ├── brnlenet2_solver.prototxt.template │ │ │ │ ├── brnlenet_solver.prototxt.template │ │ │ │ ├── resnetbrnn20_solver.prototxt.template │ │ │ │ ├── resnetbrn20_solver.prototxt.template │ │ │ │ ├── create_cifar10.sh.template │ │ │ │ ├── ps_config_brnlenet1 │ │ │ │ ├── ps_config_brnlenet2 │ │ │ │ ├── ps_config_inception │ │ │ │ ├── ps_config_inceptionbrn │ │ │ │ ├── ps_config_inceptionbrn1 │ │ │ │ ├── ps_config_inceptionbrn2 │ │ │ │ ├── ps_config_lenet │ │ │ │ ├── ps_config_resnetbrnn20 │ │ │ │ ├── ps_config_bnlenet │ │ │ │ ├── ps_config_gnlenet │ │ │ │ ├── ps_config_brnlenet │ │ │ │ ├── ps_config_resnet20 │ │ │ │ ├── ps_config_resnetbrn20 │ │ │ │ ├── ps_config_alexnet │ │ │ │ ├── ps_config_googlenet │ │ │ │ ├── inception_solver.prototxt.template │ │ │ │ ├── inceptionbrn1_solver.prototxt.template │ │ │ │ ├── inceptionbrn_solver.prototxt.template │ │ │ │ └── inceptionbrn2_solver.prototxt.template │ │ │ ├── mxnet_converter.py │ │ │ ├── 5parts │ │ │ │ ├── machinefile │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── create_cifar10_pdsh.sh │ │ │ │ ├── bnlenet_solver.prototxt.template │ │ │ │ ├── gnlenet_solver.prototxt.template │ │ │ │ ├── alexnet_solver.prototxt.template │ │ │ │ ├── resnet20_solver.prototxt.template │ │ │ │ ├── googlenet_solver.prototxt.template │ │ │ │ ├── resnet20e_solver.prototxt.template │ │ │ │ ├── resnetgn20_solver.prototxt.template │ │ │ │ ├── googlenete_solver.prototxt.template │ │ │ │ ├── lenet_solver.prototxt.template │ │ │ │ ├── brnlenet_solver.prototxt.template │ │ │ │ ├── create_cifar10_skew.sh.template │ │ │ │ ├── create_cifar10.sh.template │ │ │ │ ├── ps_config_brnlenet │ │ │ │ ├── ps_config_alexnet │ │ │ │ ├── ps_config_bnlenet │ │ │ │ ├── ps_config_googlenet │ │ │ │ ├── ps_config_lenet │ │ │ │ ├── ps_config_resnet20 │ │ │ │ ├── ps_config_resnet20e │ │ │ │ ├── ps_config_googlenete │ │ │ │ ├── ps_config_gnlenet │ │ │ │ ├── ps_config_resnetgn20 │ │ │ │ ├── train_lenet.sh │ │ │ │ ├── train_alexnet.sh │ │ │ │ ├── train_bnlenet.sh │ │ │ │ ├── train_gnlenet.sh │ │ │ │ ├── train_brnlenet.sh │ │ │ │ ├── train_resnet20.sh │ │ │ │ ├── train_googlenet.sh │ │ │ │ ├── train_resnet20e.sh │ │ │ │ ├── train_googlenete.sh │ │ │ │ └── train_resnetgn20.sh │ │ │ ├── 10parts │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── machinefile │ │ │ │ ├── create_cifar10_pdsh.sh │ │ │ │ ├── alexnet_solver.prototxt.template │ │ │ │ ├── lenet_solver.prototxt.template │ │ │ │ ├── resnet20_solver.prototxt.template │ │ │ │ ├── create_cifar10.sh.template │ │ │ │ ├── ps_config_alexnet │ │ │ │ ├── ps_config_lenet │ │ │ │ └── ps_config_resnet20 │ │ │ ├── train_full_sigmoid.sh │ │ │ ├── train_full_sigmoid_bn.sh │ │ │ ├── train_quick.sh │ │ │ ├── create_cifar10.sh │ │ │ ├── train_full.sh │ │ │ ├── cifar10_quick_solver.prototxt │ │ │ ├── cifar10_quick_solver_lr1.prototxt │ │ │ ├── cifar10_full_solver.prototxt │ │ │ ├── cifar10_full_solver_lr1.prototxt │ │ │ ├── cifar10_full_solver_lr2.prototxt │ │ │ ├── cifar10_full_sigmoid_solver.prototxt │ │ │ └── cifar10_full_sigmoid_solver_bn.prototxt │ │ ├── casia │ │ │ └── 4parts │ │ │ │ ├── machinefile │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── face_solver.prototxt.template │ │ │ │ ├── ps_config_face │ │ │ │ └── train_face.sh │ │ ├── geoanimal │ │ │ ├── 5parts │ │ │ │ ├── machinefile │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── run_create_geoanimal.sh │ │ │ │ ├── googlenetv2_solver.prototxt.template │ │ │ │ ├── create_geoanimal.sh.template │ │ │ │ └── ps_config_googlenetv2 │ │ │ └── 13parts │ │ │ │ ├── cleanup_workers.sh │ │ │ │ ├── machinefile │ │ │ │ ├── run_create_geoanimal.sh │ │ │ │ ├── googlenetv2_solver.prototxt.template │ │ │ │ ├── create_geoanimal.sh.template │ │ │ │ └── ps_config_googlenetv2 │ │ ├── femnist │ │ │ └── 10parts │ │ │ │ ├── resnet20_solver.prototxt.template │ │ │ │ └── ps_config_resnet20 │ │ └── CMakeLists.txt │ ├── matlab │ │ ├── hdf5creation │ │ │ └── .gitignore │ │ └── +caffe │ │ │ ├── private │ │ │ ├── CHECK.m │ │ │ ├── CHECK_FILE_EXIST.m │ │ │ └── is_valid_handle.m │ │ │ ├── imagenet │ │ │ └── ilsvrc_2012_mean.mat │ │ │ ├── set_mode_cpu.m │ │ │ ├── set_mode_gpu.m │ │ │ ├── version.m │ │ │ ├── reset_all.m │ │ │ ├── set_device.m │ │ │ ├── get_solver.m │ │ │ ├── run_tests.m │ │ │ ├── +test │ │ │ └── test_io.m │ │ │ ├── Layer.m │ │ │ └── get_net.m │ ├── make_all.sh │ ├── python │ │ ├── caffe │ │ │ ├── imagenet │ │ │ │ └── ilsvrc_2012_mean.npy │ │ │ ├── test │ │ │ │ └── test_layer_type_list.py │ │ │ └── __init__.py │ │ ├── requirements.txt │ │ └── read_lmdb.py │ ├── tools │ │ ├── test_net.cpp │ │ ├── device_query.cpp │ │ ├── finetune_net.cpp │ │ ├── train_net.cpp │ │ ├── net_speed_benchmark.cpp │ │ └── CMakeLists.txt │ ├── INSTALL.md │ ├── scripts │ │ ├── summarize-log.sh │ │ ├── modify-net.py │ │ ├── build_docs.sh │ │ ├── downsample.py │ │ ├── download_model_from_gist.sh │ │ ├── make-layers.py │ │ ├── duplicate.py │ │ ├── summarize-log.py │ │ ├── copy_notebook.py │ │ ├── summarize-loss.py │ │ ├── travis │ │ │ └── travis_setup_makefile_config.sh │ │ ├── gather_examples.sh │ │ ├── summarize-accuracy2.py │ │ └── upload_model_to_gist.sh │ ├── cmake │ │ ├── Templates │ │ │ ├── CaffeConfigVersion.cmake.in │ │ │ └── caffe_config.h.in │ │ └── Modules │ │ │ ├── FindSnappy.cmake │ │ │ └── FindLMDB.cmake │ ├── include │ │ └── caffe │ │ │ ├── util │ │ │ ├── format.hpp │ │ │ ├── signal_handler.h │ │ │ ├── insert_splits.hpp │ │ │ ├── blocking_queue.hpp │ │ │ ├── gpu_util.cuh │ │ │ ├── hdf5.hpp │ │ │ ├── db.hpp │ │ │ ├── rng.hpp │ │ │ └── benchmark.hpp │ │ │ ├── caffe.hpp │ │ │ └── layers │ │ │ ├── neuron_layer.hpp │ │ │ └── data_layer.hpp │ ├── data │ │ └── cifar10 │ │ │ └── get_cifar10.sh │ ├── CONTRIBUTORS.md │ └── get_cifar10_results.sh └── helloworld │ ├── Makefile │ └── README.md ├── scripts ├── install-geeps-deps-ubuntu14.sh ├── install-geeps-deps-ubuntu16.sh ├── install-caffe-deps-ubuntu14.sh └── install-caffe-deps-ubuntu16.sh └── SConstruct /apps/caffe/docs/tutorial/fig/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/solvers/sgd_solver.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layers/base_data_layer.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/caffe/docs/CNAME: -------------------------------------------------------------------------------- 1 | caffe.berkeleyvision.org 2 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/1part/machinefile: -------------------------------------------------------------------------------- 1 | h0-dfge 2 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/1parts/machinefile: -------------------------------------------------------------------------------- 1 | localhost 2 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/machinefile: -------------------------------------------------------------------------------- 1 | h0 2 | h1 3 | -------------------------------------------------------------------------------- /apps/caffe/matlab/hdf5creation/.gitignore: -------------------------------------------------------------------------------- 1 | *.h5 2 | list.txt 3 | -------------------------------------------------------------------------------- /apps/caffe/examples/casia/4parts/machinefile: -------------------------------------------------------------------------------- 1 | h0 2 | h1 3 | h2 4 | h3 5 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/mxnet_converter.py: -------------------------------------------------------------------------------- 1 | ../../scripts/mxnet_converter.py -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/machinefile: -------------------------------------------------------------------------------- 1 | h0 2 | h1 3 | h2 4 | h3 5 | h4 6 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/5parts/machinefile: -------------------------------------------------------------------------------- 1 | h0 2 | h1 3 | h2 4 | h3 5 | h4 6 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/machinefile: -------------------------------------------------------------------------------- 1 | h0 2 | h1 3 | h2 4 | h3 5 | h4 6 | h5 7 | h6 8 | h7 9 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/test/test_data/solver_data_list.txt: -------------------------------------------------------------------------------- 1 | src/caffe/test/test_data/solver_data.h5 2 | -------------------------------------------------------------------------------- /apps/caffe/make_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd ../../ 4 | scons -j4 5 | cd apps/caffe 6 | rm build/tools/*.bin 7 | make -j4 8 | 9 | -------------------------------------------------------------------------------- /apps/caffe/docs/images/caffeine-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/images/caffeine-icon.png -------------------------------------------------------------------------------- /apps/caffe/docs/tutorial/fig/forward.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/tutorial/fig/forward.jpg -------------------------------------------------------------------------------- /apps/caffe/docs/tutorial/fig/layer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/tutorial/fig/layer.jpg -------------------------------------------------------------------------------- /apps/caffe/docs/tutorial/fig/logreg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/tutorial/fig/logreg.jpg -------------------------------------------------------------------------------- /apps/caffe/docs/tutorial/fig/backward.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/tutorial/fig/backward.jpg -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/private/CHECK.m: -------------------------------------------------------------------------------- 1 | function CHECK(expr, error_msg) 2 | 3 | if ~expr 4 | error(error_msg); 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /apps/caffe/docs/images/GitHub-Mark-64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/images/GitHub-Mark-64px.png -------------------------------------------------------------------------------- /apps/caffe/examples/casia/4parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/casia/4parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/ps_config_inception: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=4000000000 4 | layers_per_table=10 5 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/ps_config_inception_v3: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=4000000000 4 | layers_per_table=10 5 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_inception: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=4000000000 4 | layers_per_table=10 5 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_inception_v3: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=4000000000 4 | layers_per_table=10 5 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/docs/tutorial/fig/forward_backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/docs/tutorial/fig/forward_backward.png -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/10parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/2parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/test/test_data/sample_data.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/src/caffe/test/test_data/sample_data.h5 -------------------------------------------------------------------------------- /apps/caffe/src/caffe/test/test_data/solver_data.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/src/caffe/test/test_data/solver_data.h5 -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/machinefile: -------------------------------------------------------------------------------- 1 | gaia1 2 | gaia2 3 | gaia3 4 | gaia4 5 | gaia5 6 | gaia6 7 | gaia7 8 | gaia8 9 | gaia9 10 | gaia10 11 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/13parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/geoanimal/13parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/5parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/geoanimal/5parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/cleanup_workers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/11parts/machinefile "pkill caffe_geeps" 4 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/imagenet/ilsvrc_2012_mean.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/matlab/+caffe/imagenet/ilsvrc_2012_mean.mat -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/set_mode_cpu.m: -------------------------------------------------------------------------------- 1 | function set_mode_cpu() 2 | % set_mode_cpu() 3 | % set Caffe to CPU mode 4 | 5 | caffe_('set_mode_cpu'); 6 | 7 | end 8 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/set_mode_gpu.m: -------------------------------------------------------------------------------- 1 | function set_mode_gpu() 2 | % set_mode_gpu() 3 | % set Caffe to GPU mode 4 | 5 | caffe_('set_mode_gpu'); 6 | 7 | end 8 | -------------------------------------------------------------------------------- /apps/caffe/python/caffe/imagenet/ilsvrc_2012_mean.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/python/caffe/imagenet/ilsvrc_2012_mean.npy -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/ps_config_caffenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=4500000000 4 | mm_warning_level=3 5 | layers_per_table=1 6 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_caffenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=4500000000 4 | mm_warning_level=3 5 | layers_per_table=1 6 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/version.m: -------------------------------------------------------------------------------- 1 | function version_str = version() 2 | % version() 3 | % show Caffe's version. 4 | 5 | version_str = caffe_('version'); 6 | 7 | end 8 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/test/test_data/sample_data_2_gzip.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinhsieh/non_iid_dml/HEAD/apps/caffe/src/caffe/test/test_data/sample_data_2_gzip.h5 -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/13parts/machinefile: -------------------------------------------------------------------------------- 1 | gaia1 2 | gaia2 3 | gaia3 4 | gaia4 5 | gaia5 6 | gaia6 7 | gaia7 8 | gaia8 9 | gaia9 10 | gaia10 11 | gaia11 12 | gaia12 13 | gaia13 14 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/private/CHECK_FILE_EXIST.m: -------------------------------------------------------------------------------- 1 | function CHECK_FILE_EXIST(filename) 2 | 3 | if exist(filename, 'file') == 0 4 | error('%s does not exist', filename); 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/train_full_sigmoid.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | TOOLS=./build/tools 4 | 5 | $TOOLS/caffe train \ 6 | --solver=examples/cifar10/cifar10_full_sigmoid_solver.prototxt 7 | 8 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/train_full_sigmoid_bn.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | TOOLS=./build/tools 4 | 5 | $TOOLS/caffe train \ 6 | --solver=examples/cifar10/cifar10_full_sigmoid_solver_bn.prototxt 7 | 8 | -------------------------------------------------------------------------------- /apps/caffe/tools/test_net.cpp: -------------------------------------------------------------------------------- 1 | #include "caffe/caffe.hpp" 2 | 3 | int main(int argc, char** argv) { 4 | LOG(FATAL) << "Deprecated. Use caffe test --model=... " 5 | "--weights=... instead."; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/machinefile: -------------------------------------------------------------------------------- 1 | 10.117.1.40 2 | 10.117.1.24 3 | 10.117.1.4 4 | 10.117.1.37 5 | 10.117.1.38 6 | 10.117.1.33 7 | 10.117.1.27 8 | 10.117.1.29 9 | 10.117.1.31 10 | 10.117.1.17 11 | 10.117.1.19 -------------------------------------------------------------------------------- /apps/caffe/src/gtest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(gtest STATIC EXCLUDE_FROM_ALL gtest.h gtest-all.cpp) 2 | caffe_default_properties(gtest) 3 | 4 | #add_library(gtest_main gtest_main.cc) 5 | #target_link_libraries(gtest_main gtest) 6 | -------------------------------------------------------------------------------- /apps/caffe/tools/device_query.cpp: -------------------------------------------------------------------------------- 1 | #include "caffe/common.hpp" 2 | 3 | int main(int argc, char** argv) { 4 | LOG(FATAL) << "Deprecated. Use caffe device_query " 5 | "[--device_id=0] instead."; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/reset_all.m: -------------------------------------------------------------------------------- 1 | function reset_all() 2 | % reset_all() 3 | % clear all solvers and stand-alone nets and reset Caffe to initial status 4 | 5 | caffe_('reset'); 6 | is_valid_handle('get_new_init_key'); 7 | 8 | end 9 | -------------------------------------------------------------------------------- /apps/caffe/tools/finetune_net.cpp: -------------------------------------------------------------------------------- 1 | #include "caffe/caffe.hpp" 2 | 3 | int main(int argc, char** argv) { 4 | LOG(FATAL) << "Deprecated. Use caffe train --solver=... " 5 | "[--weights=...] instead."; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /apps/caffe/tools/train_net.cpp: -------------------------------------------------------------------------------- 1 | #include "caffe/caffe.hpp" 2 | 3 | int main(int argc, char** argv) { 4 | LOG(FATAL) << "Deprecated. Use caffe train --solver=... " 5 | "[--snapshot=...] instead."; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/resume_training.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ./build/tools/caffe train \ 4 | --solver=models/bvlc_reference_caffenet/solver.prototxt \ 5 | --snapshot=models/bvlc_reference_caffenet/caffenet_train_10000.solverstate.h5 6 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/tools/net_speed_benchmark.cpp: -------------------------------------------------------------------------------- 1 | #include "caffe/caffe.hpp" 2 | 3 | int main(int argc, char** argv) { 4 | LOG(FATAL) << "Deprecated. Use caffe time --model=... " 5 | "[--iterations=50] [--gpu] [--device_id=0]"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/1parts/create_cifar10_pdsh.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | python scripts/duplicate.py examples/cifar10/1parts/create_cifar10.sh 1 4 | pdsh -R ssh -w ^examples/cifar10/1parts/machinefile "cd $(pwd) && ./examples/cifar10/1parts/create_cifar10.sh.%n" 5 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/create_cifar10_pdsh.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | python scripts/duplicate.py examples/cifar10/5parts/create_cifar10.sh 5 4 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./examples/cifar10/5parts/create_cifar10.sh.%n" 5 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/5parts/run_create_geoanimal.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | python scripts/duplicate.py examples/geoanimal/5parts/create_geoanimal.sh 5 4 | pdsh -R ssh -w ^examples/geoanimal/5parts/machinefile "cd $(pwd) && ./examples/geoanimal/5parts/create_geoanimal.sh.%n" 5 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/1part/ps_config_caffenet: -------------------------------------------------------------------------------- 1 | hostfile=examples/imagenet/1part/machinefile 2 | num_channels=4 3 | slack=0 4 | thread_cache_capacity=0 5 | gpu_process_cache_capacity=-1 6 | gpu_local_storage_capacity=-1 7 | gpu_memory_capacity=9000000 8 | layers_per_table=1 9 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/1part/ps_config_googlenet: -------------------------------------------------------------------------------- 1 | hostfile=examples/imagenet/8parts/machinefile 2 | num_channels=4 3 | slack=0 4 | thread_cache_capacity=0 5 | gpu_process_cache_capacity=-1 6 | gpu_local_storage_capacity=-1 7 | gpu_memory_capacity=8000000 8 | layers_per_table=10 9 | -------------------------------------------------------------------------------- /apps/helloworld/Makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | CFLAGS = -g -O3 3 | INCLUDE_PATH = -I../../include 4 | LIBPATH = -L../../build 5 | LIBS = -lrt -Wl,-rpath,\$$ORIGIN/../../build -lgeeps 6 | 7 | all: Makefile helloworld.cpp 8 | $(CC) $(CFLAGS) helloworld.cpp $(INCLUDE_PATH) $(LIBPATH) $(LIBS) -o helloworld 9 | -------------------------------------------------------------------------------- /apps/caffe/scripts/summarize-log.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | python scripts/summarize-loss.py $1/output.txt $2 $3 > $1/losses.txt 4 | python scripts/summarize-accuracy.py $1/output.txt $2 0 $3 > $1/accuracy.txt 5 | python scripts/summarize-accuracy.py $1/output.txt $2 1 $3 > $1/accuracy-training.txt 6 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/set_device.m: -------------------------------------------------------------------------------- 1 | function set_device(device_id) 2 | % set_device(device_id) 3 | % set Caffe's GPU device ID 4 | 5 | CHECK(isscalar(device_id) && device_id >= 0, ... 6 | 'device_id must be non-negative integer'); 7 | device_id = double(device_id); 8 | 9 | caffe_('set_device', device_id); 10 | 11 | end 12 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/create_cifar10_pdsh.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python scripts/duplicate.py examples/cifar10/2parts/create_cifar10.sh 2 4 | for n in 0 1; 5 | do 6 | ./examples/cifar10/2parts/create_cifar10.sh.$n 7 | done 8 | #pdsh -R ssh -w ^examples/cifar10/2parts/machinefile "cd $(pwd) && ./examples/cifar10/2parts/create_cifar10.sh.%n" 9 | -------------------------------------------------------------------------------- /apps/caffe/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 -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/get_solver.m: -------------------------------------------------------------------------------- 1 | function solver = get_solver(solver_file) 2 | % solver = get_solver(solver_file) 3 | % Construct a Solver object from solver_file 4 | 5 | CHECK(ischar(solver_file), 'solver_file must be a string'); 6 | CHECK_FILE_EXIST(solver_file); 7 | pSolver = caffe_('get_solver', solver_file); 8 | solver = caffe.Solver(pSolver); 9 | 10 | end 11 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/make_imagenet_mean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Compute the mean image from the imagenet training lmdb 3 | # N.B. this is available in data/ilsvrc12 4 | 5 | EXAMPLE=examples/imagenet 6 | DATA=data/ilsvrc12 7 | TOOLS=build/tools 8 | 9 | $TOOLS/compute_image_mean $EXAMPLE/ilsvrc12_train_lmdb \ 10 | $DATA/imagenet_mean.binaryproto 11 | 12 | echo "Done." 13 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/create_cifar10_pdsh.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | python scripts/duplicate.py examples/cifar10/10parts/create_cifar10.sh 10 4 | 5 | for n in 0 1 2 3 4 5 6 7 8 9 6 | do 7 | ./examples/cifar10/10parts/create_cifar10.sh.${n} 8 | done 9 | 10 | #pdsh -R ssh -w ^examples/cifar10/10parts/machinefile "cd $(pwd) && ./examples/cifar10/10parts/create_cifar10.sh.%n" 11 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/train_quick.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | TOOLS=./build/tools 4 | 5 | $TOOLS/caffe train \ 6 | --solver=examples/cifar10/cifar10_quick_solver.prototxt 7 | 8 | # reduce learning rate by factor of 10 after 8 epochs 9 | $TOOLS/caffe train \ 10 | --solver=examples/cifar10/cifar10_quick_solver_lr1.prototxt \ 11 | --snapshot=examples/cifar10/cifar10_quick_iter_4000.solverstate.h5 12 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layers/neuron_layer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/neuron_layer.hpp" 4 | 5 | namespace caffe { 6 | 7 | template 8 | void NeuronLayer::Reshape(const vector*>& bottom, 9 | const vector*>& top) { 10 | top[0]->ReshapeLike(*bottom[0]); 11 | } 12 | 13 | INSTANTIATE_CLASS(NeuronLayer); 14 | 15 | } // namespace caffe 16 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/13parts/run_create_geoanimal.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | python scripts/duplicate.py examples/geoanimal/13parts/create_geoanimal.sh 13 4 | 5 | #for n in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 6 | #do 7 | # ./examples/geoanimal/13parts/create_geoanimal.sh.${n} 8 | #done 9 | pdsh -R ssh -w ^examples/geoanimal/13parts/machinefile "cd $(pwd) && ./examples/geoanimal/13parts/create_geoanimal.sh.%n" 10 | -------------------------------------------------------------------------------- /apps/caffe/python/caffe/test/test_layer_type_list.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import caffe 4 | 5 | class TestLayerTypeList(unittest.TestCase): 6 | 7 | def test_standard_types(self): 8 | #removing 'Data' from list 9 | for type_name in ['Data', 'Convolution', 'InnerProduct']: 10 | self.assertIn(type_name, caffe.layer_type_list(), 11 | '%s not in layer_type_list()' % type_name) 12 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/alexnet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/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: "examples/imagenet/8parts/alexnet_train.%" 14 | solver_mode: GPU 15 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/alexnet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/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: "examples/imagenet/8parts/alexnet_train.%" 14 | solver_mode: GPU 15 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/python/caffe/__init__.py: -------------------------------------------------------------------------------- 1 | from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver 2 | from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list 3 | from ._caffe import __version__ 4 | from .proto.caffe_pb2 import TRAIN, TEST 5 | from .classifier import Classifier 6 | from .detector import Detector 7 | from . import io 8 | from .net_spec import layers, params, NetSpec, to_proto 9 | -------------------------------------------------------------------------------- /apps/caffe/scripts/modify-net.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from datetime import datetime, timedelta 4 | 5 | input_file_name = sys.argv[1] 6 | 7 | input_file = open(input_file_name, 'r') 8 | last_line = '' 9 | for line in input_file: 10 | line = line.split('\n')[0] 11 | if line == ' type: "BatchNorm"': 12 | extra_line1 = last_line[:-1] + '/temp1"' 13 | extra_line2 = last_line[:-1] + '/temp2"' 14 | print extra_line1 15 | print extra_line2 16 | print line 17 | last_line = line 18 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/run_tests.m: -------------------------------------------------------------------------------- 1 | function results = run_tests() 2 | % results = run_tests() 3 | % run all tests in this caffe matlab wrapper package 4 | 5 | % use CPU for testing 6 | caffe.set_mode_cpu(); 7 | 8 | % reset caffe before testing 9 | caffe.reset_all(); 10 | 11 | % put all test cases here 12 | results = [... 13 | run(caffe.test.test_net) ... 14 | run(caffe.test.test_solver) ... 15 | run(caffe.test.test_io) ]; 16 | 17 | % reset caffe after testing 18 | caffe.reset_all(); 19 | 20 | end 21 | -------------------------------------------------------------------------------- /apps/caffe/scripts/build_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Build documentation for display in web browser. 3 | 4 | PORT=${1:-4000} 5 | 6 | echo "usage: build_docs.sh [port]" 7 | 8 | # Find the docs dir, no matter where the script is called 9 | ROOT_DIR="$( cd "$(dirname "$0")"/.. ; pwd -P )" 10 | cd $ROOT_DIR 11 | 12 | # Gather docs. 13 | scripts/gather_examples.sh 14 | 15 | # Generate developer docs. 16 | make docs 17 | 18 | # Display docs using web server. 19 | cd docs 20 | jekyll serve -w -s . -d _site --port=$PORT 21 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/format.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_UTIL_FORMAT_H_ 2 | #define CAFFE_UTIL_FORMAT_H_ 3 | 4 | #include // NOLINT(readability/streams) 5 | #include // NOLINT(readability/streams) 6 | #include 7 | 8 | namespace caffe { 9 | 10 | inline std::string format_int(int n, int numberOfLeadingZeros = 0 ) { 11 | std::ostringstream s; 12 | s << std::setw(numberOfLeadingZeros) << std::setfill('0') << n; 13 | return s.str(); 14 | } 15 | 16 | } 17 | 18 | #endif // CAFFE_UTIL_FORMAT_H_ 19 | -------------------------------------------------------------------------------- /apps/caffe/python/read_lmdb.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import caffe 3 | import lmdb 4 | from collections import defaultdict 5 | 6 | lmdb_env = lmdb.open(sys.argv[1]) 7 | lmdb_txn = lmdb_env.begin() 8 | lmdb_cursor = lmdb_txn.cursor() 9 | datum = caffe.proto.caffe_pb2.Datum() 10 | 11 | label_count = defaultdict(int) 12 | count = 0 13 | 14 | for key, value in lmdb_cursor: 15 | datum.ParseFromString(value) 16 | label = datum.label 17 | label_count[label] += 1 18 | count += 1 19 | 20 | print(label_count) 21 | print(count) 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/5parts/googlenetv2_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/geoanimal/5parts/googlenetv2_train_val.prototxt.%" 2 | test_iter: 230 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.004 8 | lr_policy: "poly" 9 | power: 0.5 10 | max_iter: 240000 11 | momentum: 0.9 12 | weight_decay: 0.0002 13 | snapshot: 40000 14 | snapshot_prefix: "geoanimal_googlenetv2_5parts_gaia_th_0.20_lm_1_shuffleddata/googlenetv2_snapshot" 15 | solver_mode: GPU 16 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/googlenetv2_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/googlenetv2.prototxt.%" 2 | test_iter: 195 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 40 6 | average_loss: 40 7 | base_lr: 0.0025 8 | lr_policy: "poly" 9 | power: 0.5 10 | max_iter: 300000 11 | momentum: 0.9 12 | weight_decay: 0.0002 13 | snapshot: 40000 14 | snapshot_prefix: "imagenet_googlenetv2_8parts_dgc_epoch_10000_lm_0_dmm_0_skeweddata_stat_lan/resnet_snapshot" 15 | solver_mode: GPU 16 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/1part/caffenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/1part/caffenet_train_val.prototxt.%" 2 | test_iter: 24 3 | test_interval: 1000 4 | test_initialization: false 5 | # base_lr: 0.01 6 | base_lr: 0.0036 7 | lr_policy: "step" 8 | gamma: 0.1 9 | stepsize: 100000 10 | display: 20 11 | max_iter: 50000000 12 | # max_iter: 40 13 | momentum: 0.9 14 | weight_decay: 0.000125 15 | random_seed: 12345678 16 | snapshot: 10000000 17 | snapshot_prefix: "examples/imagenet/1part/caffenet_snapshot" 18 | solver_mode: GPU 19 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/1parts/gnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/1parts/gnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.01 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_gnlenet_1parts_bsp_shuffledata/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /scripts/install-geeps-deps-ubuntu14.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update 2 | sudo apt-get install -y --force-yes libboost-thread-dev 3 | sudo apt-get install -y --force-yes libboost-program-options-dev 4 | sudo apt-get install -y --force-yes libgoogle-glog-dev 5 | sudo apt-get install -y --force-yes libgflags-dev 6 | sudo apt-get install -y --force-yes libatlas-base-dev 7 | sudo apt-get install -y --force-yes libtbb-dev 8 | sudo apt-get install -y --force-yes libzmq-dev 9 | sudo apt-get install -y --force-yes scons 10 | sudo apt-get install -y --force-yes pdsh 11 | -------------------------------------------------------------------------------- /scripts/install-geeps-deps-ubuntu16.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update 2 | sudo apt-get install -y --force-yes libboost-thread-dev 3 | sudo apt-get install -y --force-yes libboost-program-options-dev 4 | sudo apt-get install -y --force-yes libgoogle-glog-dev 5 | sudo apt-get install -y --force-yes libgflags-dev 6 | sudo apt-get install -y --force-yes libatlas-base-dev 7 | sudo apt-get install -y --force-yes libtbb-dev 8 | sudo apt-get install -y --force-yes libzmq-dev 9 | sudo apt-get install -y --force-yes scons 10 | sudo apt-get install -y --force-yes pdsh 11 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/alexnet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/10parts/alexnet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.0001 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_alexnet_10parts_bsp_shuffledata/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/1part/inception_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/1part/inception_train_val.prototxt.%" 2 | test_iter: 1000 3 | test_interval: 4000 4 | test_initialization: false 5 | snapshot_after_train: false 6 | display: 40 7 | average_loss: 40 8 | base_lr: 0.045 9 | lr_policy: "step" 10 | stepsize: 6400 11 | gamma: 0.96 12 | max_iter: 1200000 13 | momentum: 0.9 14 | weight_decay: 0.0002 15 | random_seed: 1234568 16 | snapshot: 40000 17 | snapshot_prefix: "examples/imagenet/1part/inception_snapshot" 18 | solver_mode: GPU 19 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/resnet_50_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/resnet_50.prototxt.%" 2 | test_iter: 195 3 | test_interval: 10000 4 | #test_interval: 2 5 | test_initialization: false 6 | display: 20 7 | average_loss: 20 8 | base_lr: 0.0125 9 | max_iter: 320000 10 | lr_policy: "poly" 11 | power: 1 12 | momentum: 0.9 13 | weight_decay: 0.0001 14 | random_seed: 1234568 15 | snapshot: 40000 16 | snapshot_prefix: "imagenet_resnet10_8parts_bsp_lr_0125_epoch_64_shuffledata_stat_lan/resnet_snapshot" 17 | solver_mode: GPU 18 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/gnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/gnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_gnlenet_2parts_fedavg_iter_50_skeweddata/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/inception_v3_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/inception_v3_train_val.prototxt.%" 2 | test_iter: 196 3 | test_interval: 5004 4 | test_initialization: false 5 | snapshot_after_train: false 6 | display: 40 7 | average_loss: 40 8 | base_lr: 0.01 9 | lr_policy: "step" 10 | stepsize: 800 11 | gamma: 1 12 | max_iter: 1200000 13 | momentum: 0.9 14 | weight_decay: 0.0002 15 | random_seed: 1234568 16 | snapshot: 20000 17 | snapshot_prefix: "examples/imagenet/8parts/inception_v3_snapshot" 18 | solver_mode: GPU 19 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/inception_v3_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/inception_v3_train_val.prototxt.%" 2 | test_iter: 196 3 | test_interval: 5004 4 | test_initialization: false 5 | snapshot_after_train: false 6 | display: 40 7 | average_loss: 40 8 | base_lr: 0.01 9 | lr_policy: "step" 10 | stepsize: 800 11 | gamma: 1 12 | max_iter: 1200000 13 | momentum: 0.9 14 | weight_decay: 0.0002 15 | random_seed: 1234568 16 | snapshot: 20000 17 | snapshot_prefix: "examples/imagenet/8parts/inception_v3_snapshot" 18 | solver_mode: GPU 19 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/bnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/bnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_bnlenet_2parts_bsp_1bn_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/lenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/10parts/lenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.001 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_lenet_10parts_bsp_shuffledata/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | # type: "Nesterov" 23 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/bnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/bnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_bnlenet_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/gnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/gnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_gnlenet_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/13parts/googlenetv2_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/geoanimal/13parts/googlenetv2_train_val.prototxt.%" 2 | test_iter: 89 3 | test_interval: 10000 4 | test_initialization: false 5 | display: 50 6 | average_loss: 50 7 | base_lr: 0.002 8 | lr_policy: "poly" 9 | power: 0.5 10 | max_iter: 200000 11 | momentum: 0.9 12 | weight_decay: 0.0002 13 | snapshot: 100000 14 | snapshot_prefix: "/home/kevhsieh/mnr/geeps_gaia/apps/caffe/outputs/geoanimal_googlenetv2_13parts_bsp_shuffleddata/googlenetv2_snapshot" 15 | solver_mode: GPU 16 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/resnet20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/resnet20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnet20_2parts_fedavg_iter_2000_skeweddata_upstat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/alexnet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/alexnet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.0002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_alexnet_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/resnet20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/resnet20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnet20_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/1part/googlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/1part/googlenet_train_val.prototxt.%" 2 | test_iter: 192 3 | test_interval: 5000 4 | test_initialization: false 5 | snapshot_after_train: false 6 | display: 20 7 | average_loss: 20 8 | base_lr: 0.0036 9 | lr_policy: "step" 10 | stepsize: 320000 11 | gamma: 1 12 | max_iter: 10000000 13 | # max_iter: 40 14 | momentum: 0.9 15 | weight_decay: 0.0002 16 | random_seed: 1234568 17 | snapshot: 20000 18 | snapshot_prefix: "examples/imagenet/1part/googlenet_snapshot" 19 | solver_mode: GPU 20 | -------------------------------------------------------------------------------- /apps/helloworld/README.md: -------------------------------------------------------------------------------- 1 | # Compile and run 2 | 3 | ``` 4 | make 5 | ./helloworld 6 | ``` 7 | 8 | # Expected output 9 | 10 | ``` 11 | Finished "training", hello world! 12 | [some error messages indicating that CUDA functions are called while the driver is shut down] 13 | 14 | ``` 15 | 16 | # Known issues 17 | 18 | After the program finishes, there will be some error messages indicating that 19 | CUDA functions are called while the driver is shut down. 20 | This is because we are yet to implement the shutting-down procedures 21 | of the background working threads. 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/resnet20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/10parts/resnet20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.001 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnet20_10parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/googlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/googlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_googlenet_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/resnet20e_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/resnet20e_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnet20_5parts_fedavg_iter_2000_skeweddata_upstat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/resnetgn20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/resnetgn20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnetgn20_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/femnist/10parts/resnet20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/femnist/10parts/resnet20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 169 5 | test_interval: 1000 6 | 7 | base_lr: 0.001 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "femnist_resnet20_10parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/alexnet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/alexnet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.0005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_alexnet_2parts_gaia_lm_0_sched_0.20,0.10_shuffledata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/googlenete_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/googlenete_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_googlenete_5parts_fedavg_iter_2000_skeweddata_80p_upstat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/create_cifar10.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This script converts the cifar data into leveldb format. 3 | 4 | EXAMPLE=examples/cifar10 5 | DATA=data/cifar10 6 | DBTYPE=lmdb 7 | 8 | echo "Creating $DBTYPE..." 9 | 10 | rm -rf $EXAMPLE/cifar10_train_$DBTYPE $EXAMPLE/cifar10_test_$DBTYPE 11 | 12 | ./build/examples/cifar10/convert_cifar_data.bin $DATA $EXAMPLE $DBTYPE 13 | 14 | echo "Computing image mean..." 15 | 16 | ./build/tools/compute_image_mean -backend=$DBTYPE \ 17 | $EXAMPLE/cifar10_train_$DBTYPE $EXAMPLE/mean.binaryproto 18 | 19 | echo "Done." 20 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/googlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/googlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_googlenet_2parts_gaia_lm_0_sched_0.20,0.10_shuffledata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/lenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/lenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_lenet_2parts_gaia_th_0.50_lm_0_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | # type: "Nesterov" 23 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/lenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/lenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_lenet_5parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | # type: "Nesterov" 23 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/inception_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/inception_train_val.prototxt.%" 2 | # test_iter: 1000 3 | test_iter: 125 4 | test_interval: 5000 5 | test_initialization: false 6 | snapshot_after_train: false 7 | display: 40 8 | average_loss: 40 9 | base_lr: 0.01 10 | lr_policy: "step" 11 | # stepsize: 6400 12 | stepsize: 800 13 | gamma: 1 14 | max_iter: 1200000 15 | momentum: 0.9 16 | weight_decay: 0.0002 17 | random_seed: 1234568 18 | snapshot: 20000 19 | snapshot_prefix: "examples/imagenet/8parts/inception_snapshot" 20 | solver_mode: GPU 21 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/brnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/5parts/brnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.002 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_brnlenet_5parts_bsp_s_20000_rs_40000_ds_30000_r_4_d_6_m_0.99_skewdata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/inception_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/inception_train_val.prototxt.%" 2 | # test_iter: 1000 3 | test_iter: 125 4 | test_interval: 5000 5 | test_initialization: false 6 | snapshot_after_train: false 7 | display: 40 8 | average_loss: 40 9 | base_lr: 0.01 10 | lr_policy: "step" 11 | # stepsize: 6400 12 | stepsize: 800 13 | gamma: 1 14 | max_iter: 1200000 15 | momentum: 0.9 16 | weight_decay: 0.0002 17 | random_seed: 1234568 18 | snapshot: 20000 19 | snapshot_prefix: "examples/imagenet/8parts/inception_snapshot" 20 | solver_mode: GPU 21 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "caffe/layer.hpp" 3 | 4 | namespace caffe { 5 | 6 | template 7 | void Layer::InitMutex() { 8 | forward_mutex_.reset(new boost::mutex()); 9 | } 10 | 11 | template 12 | void Layer::Lock() { 13 | if (IsShared()) { 14 | forward_mutex_->lock(); 15 | } 16 | } 17 | 18 | template 19 | void Layer::Unlock() { 20 | if (IsShared()) { 21 | forward_mutex_->unlock(); 22 | } 23 | } 24 | 25 | INSTANTIATE_CLASS(Layer); 26 | 27 | } // namespace caffe 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/casia/4parts/face_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/casia/4parts/face_train_test.prototxt.%" 2 | test_iter: 100 3 | test_interval: 100000 4 | test_initialization: false 5 | 6 | base_lr: 0.025 7 | lr_policy: "multistep" 8 | gamma: 0.1 9 | 10 | #iter_size: 1 11 | stepvalue: 16000 12 | stepvalue: 24000 13 | max_iter: 28000 14 | #max_iter: 10 15 | 16 | display: 100 17 | momentum: 0.9 18 | weight_decay: 0.0005 19 | random_seed: 0 20 | snapshot: 4000 21 | snapshot_prefix: "face_4parts_dgc_epoch_15084_lm_0_dmm_0_skeweddata_2dc_stat_lan/face_snapshot" 22 | 23 | solver_mode: GPU 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/brnlenet1_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/brnlenet1_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_brnlenet_2parts_bsp_s_20000_rs_40000_ds_30000_r_4_d_6_m_0.999_skewdata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/brnlenet2_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/brnlenet2_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_brnlenet_2parts_bsp_s_15000_rs_40000_ds_30000_r_4_d_6_e_0.0001_skewdata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/brnlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/brnlenet_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | stepvalue: 32000 10 | stepvalue: 48000 11 | 12 | gamma: 0.1 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | snapshot_prefix: "cifar10_brnlenet_2parts_bsp_s_5000_rs_20000_ds_20000_r_4_d_6_m_0.99__gc_10_skewdata_stat_lan/cifar_snapshot" 20 | solver_mode: GPU 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/resnetbrnn20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/resnetbrnn20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnetbrn20_2parts_bsp_s_25000_rs_40000_ds_40000_r_4_d_6_m_0.99_skewdata_stat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/resnetbrn20_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/cifar10/2parts/resnetbrn20_train_val.prototxt.%" 2 | 3 | test_initialization: false 4 | test_iter: 100 5 | test_interval: 1000 6 | 7 | base_lr: 0.005 8 | lr_policy: "multistep" 9 | gamma: 0.1 10 | stepvalue: 32000 11 | stepvalue: 48000 12 | 13 | momentum: 0.9 14 | weight_decay: 0.0005 15 | 16 | display: 100 17 | max_iter: 64000 18 | snapshot: 10000 19 | solver_mode: GPU 20 | snapshot_prefix: "cifar10_resnetbrn20_2parts_bsp_s_5000_rs_20000_ds_20000_r_4_d_6_m_0.99__gc_10_skewdata_stat_lan/cifar_snapshot" 21 | random_seed: 0 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/train_full.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | TOOLS=./build/tools 4 | 5 | $TOOLS/caffe train \ 6 | --solver=examples/cifar10/cifar10_full_solver.prototxt 7 | 8 | # reduce learning rate by factor of 10 9 | $TOOLS/caffe train \ 10 | --solver=examples/cifar10/cifar10_full_solver_lr1.prototxt \ 11 | --snapshot=examples/cifar10/cifar10_full_iter_60000.solverstate.h5 12 | 13 | # reduce learning rate by factor of 10 14 | $TOOLS/caffe train \ 15 | --solver=examples/cifar10/cifar10_full_solver_lr2.prototxt \ 16 | --snapshot=examples/cifar10/cifar10_full_iter_65000.solverstate.h5 17 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/ps_config_googlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=10000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=1 8 | num_dc=11 9 | mirror_update_threshold=0.05 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.05 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.12 16 | iters_reach_lower_bound=50000 17 | slack_table_limit=-1 18 | enable_overlay_network=1 19 | enable_olnw_multiple_routers=1 20 | enable_threshold_by_bw=1 -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/adam_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/adam_train_val.prototxt.%" 2 | test_iter: 125 3 | test_interval: 1000 4 | test_initialization: false 5 | # base_lr: 0.01 6 | # base_lr: 0.0036 7 | base_lr: 0.00125 8 | lr_policy: "step" 9 | gamma: 0.1 10 | stepsize: 100000 11 | # stepsize: 400000 12 | display: 20 13 | max_iter: 50000 14 | # max_iter: 40 15 | momentum: 0.9 16 | # weight_decay: 0.0005 17 | weight_decay: 0.00025 18 | # weight_decay: 0.000125 19 | random_seed: 12345678 20 | snapshot: 1000000 21 | snapshot_prefix: "examples/imagenet/8parts/caffenet_snapshot.%" 22 | solver_mode: GPU 23 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/adam_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/adam_train_val.prototxt.%" 2 | test_iter: 125 3 | test_interval: 1000 4 | test_initialization: false 5 | # base_lr: 0.01 6 | # base_lr: 0.0036 7 | base_lr: 0.00125 8 | lr_policy: "step" 9 | gamma: 0.1 10 | stepsize: 100000 11 | # stepsize: 400000 12 | display: 20 13 | max_iter: 50000 14 | # max_iter: 40 15 | momentum: 0.9 16 | # weight_decay: 0.0005 17 | weight_decay: 0.00025 18 | # weight_decay: 0.000125 19 | random_seed: 12345678 20 | snapshot: 1000000 21 | snapshot_prefix: "examples/imagenet/8parts/caffenet_snapshot.%" 22 | solver_mode: GPU 23 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/13parts/create_geoanimal.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Create the imagenet lmdb inputs 3 | # N.B. set the path to the imagenet train + val data dirs 4 | 5 | for data in shuffled skewed; 6 | do 7 | for tv in train val; 8 | do 9 | GLOG_logtostderr=1 build/tools/convert_imageset \ 10 | --resize_height=300 --resize_width=300 \ 11 | /geo_animal/ \ 12 | /geo_animal/13parts_${data}/${tv}.txt.% \ 13 | /geo_animal/13parts_${data}/${tv}_lmdb.% \ 14 | 2>&1 | tee /geo_animal/convert_output.% 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /apps/caffe/scripts/downsample.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from datetime import datetime, timedelta 4 | 5 | input_file = sys.argv[1] 6 | rate = int(sys.argv[2]) 7 | 8 | input_fd = open(input_file, 'r') 9 | vals = [0] * 1000 10 | count = 0 11 | for line in input_fd: 12 | strs = line.split(',') 13 | for i in range(len(strs)): 14 | vals[i] = vals[i] + float(strs[i]) 15 | count = count + 1 16 | if count % rate == 0: 17 | output_str = '' 18 | for i in range(len(strs) - 1): 19 | output_str = output_str + ('%i,' % (vals[i] / rate)) 20 | vals[i] = 0 21 | i = len(strs) - 1 22 | output_str = output_str + ('%f' % (vals[i] / rate)) 23 | vals[i] = 0 24 | print output_str 25 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/scripts/download_model_from_gist.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | GIST=$1 4 | DIRNAME=${2:-./models} 5 | 6 | if [ -z $GIST ]; then 7 | echo "usage: download_model_from_gist.sh " 8 | exit 9 | fi 10 | 11 | GIST_DIR=$(echo $GIST | tr '/' '-') 12 | MODEL_DIR="$DIRNAME/$GIST_DIR" 13 | 14 | if [ -d $MODEL_DIR ]; then 15 | echo "$MODEL_DIR already exists! Please make sure you're not overwriting anything important!" 16 | exit 17 | fi 18 | 19 | echo "Downloading Caffe model info to $MODEL_DIR ..." 20 | mkdir -p $MODEL_DIR 21 | wget https://gist.github.com/$GIST/download -O $MODEL_DIR/gist.zip 22 | unzip -j $MODEL_DIR/gist.zip -d $MODEL_DIR 23 | rm $MODEL_DIR/gist.zip 24 | echo "Done" 25 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/5parts/create_geoanimal.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Create the imagenet lmdb inputs 3 | # N.B. set the path to the imagenet train + val data dirs 4 | 5 | for data in shuffled skewed; 6 | do 7 | for tv in train val; 8 | do 9 | GLOG_logtostderr=1 build/tools/convert_imageset \ 10 | --resize_height=300 --resize_width=300 \ 11 | /data/proj/geo_animal/ \ 12 | /data/proj/geo_animal/5parts_${data}/${tv}.txt.% \ 13 | /data/proj/geo_animal/5parts_${data}/${tv}_lmdb.% \ 14 | 2>&1 | tee /data/proj/geo_animal/convert_output.% 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/googlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/11parts/googlenet_train_val.prototxt.%" 2 | test_iter: 24 3 | test_interval: 2000 4 | test_initialization: false 5 | snapshot_after_train: false 6 | display: 20 7 | average_loss: 20 8 | base_lr: 0.0036 9 | # base_lr: 0.00125 10 | lr_policy: "step" 11 | # stepsize: 320000 12 | stepsize: 40000 13 | gamma: 1 14 | #max_iter: 10000000 15 | max_iter: 80000 16 | #max_iter: 20000 17 | #max_iter: 40000 18 | #max_iter: 100 19 | # max_iter: 40 20 | momentum: 0.9 21 | # weight_decay: 0.0002 22 | weight_decay: 0.00005 23 | random_seed: 1234568 24 | snapshot: 20000 25 | snapshot_prefix: "examples/imagenet/11parts/googlenet_snapshot" 26 | solver_mode: GPU -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/caffenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/caffenet_train_val.prototxt.%" 2 | test_iter: 24 3 | test_interval: 1000 4 | test_initialization: false 5 | # base_lr: 0.01 6 | base_lr: 0.0036 7 | # base_lr: 0.00125 8 | lr_policy: "step" 9 | gamma: 0.1 10 | # stepsize: 100000 11 | stepsize: 12500 12 | # stepsize: 400000 13 | display: 20 14 | max_iter: 50000000 15 | # max_iter: 40 16 | momentum: 0.9 17 | # momentum: 0 18 | # weight_decay: 0.0005 19 | # weight_decay: 0.00025 20 | weight_decay: 0.000125 21 | # weight_decay: 0.0000625 22 | # weight_decay: 0 23 | random_seed: 12345678 24 | snapshot: 10000000 25 | snapshot_prefix: "examples/imagenet/8parts/caffenet_snapshot" 26 | solver_mode: GPU 27 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/caffenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/caffenet_train_val.prototxt.%" 2 | test_iter: 24 3 | test_interval: 1000 4 | test_initialization: false 5 | # base_lr: 0.01 6 | base_lr: 0.0036 7 | # base_lr: 0.00125 8 | lr_policy: "step" 9 | gamma: 0.1 10 | # stepsize: 100000 11 | stepsize: 12500 12 | # stepsize: 400000 13 | display: 20 14 | max_iter: 50000000 15 | # max_iter: 40 16 | momentum: 0.9 17 | # momentum: 0 18 | # weight_decay: 0.0005 19 | # weight_decay: 0.00025 20 | weight_decay: 0.000125 21 | # weight_decay: 0.0000625 22 | # weight_decay: 0 23 | random_seed: 12345678 24 | snapshot: 10000000 25 | snapshot_prefix: "examples/imagenet/8parts/caffenet_snapshot" 26 | solver_mode: GPU 27 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/caffe.hpp: -------------------------------------------------------------------------------- 1 | // caffe.hpp is the header file that you need to include in your code. It wraps 2 | // all the internal caffe header files into one for simpler inclusion. 3 | 4 | #ifndef CAFFE_CAFFE_HPP_ 5 | #define CAFFE_CAFFE_HPP_ 6 | 7 | #include "caffe/blob.hpp" 8 | #include "caffe/common.hpp" 9 | #include "caffe/filler.hpp" 10 | #include "caffe/layer.hpp" 11 | #include "caffe/layer_factory.hpp" 12 | #include "caffe/net.hpp" 13 | #include "caffe/parallel.hpp" 14 | #include "caffe/proto/caffe.pb.h" 15 | #include "caffe/solver.hpp" 16 | #include "caffe/solver_factory.hpp" 17 | #include "caffe/util/benchmark.hpp" 18 | #include "caffe/util/io.hpp" 19 | #include "caffe/util/upgrade_proto.hpp" 20 | 21 | #endif // CAFFE_CAFFE_HPP_ 22 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/+test/test_io.m: -------------------------------------------------------------------------------- 1 | classdef test_io < matlab.unittest.TestCase 2 | methods (Test) 3 | function test_read_write_mean(self) 4 | % randomly generate mean data 5 | width = 200; 6 | height = 300; 7 | channels = 3; 8 | mean_data_write = 255 * rand(width, height, channels, 'single'); 9 | % write mean data to binary proto 10 | mean_proto_file = tempname(); 11 | caffe.io.write_mean(mean_data_write, mean_proto_file); 12 | % read mean data from saved binary proto and test whether they are equal 13 | mean_data_read = caffe.io.read_mean(mean_proto_file); 14 | self.verifyEqual(mean_data_write, mean_data_read) 15 | delete(mean_proto_file); 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/googlenet_solver.prototxt.template: -------------------------------------------------------------------------------- 1 | net: "examples/imagenet/8parts/googlenet_train_val.prototxt.%" 2 | test_iter: 24 3 | test_interval: 2000 4 | test_initialization: false 5 | snapshot_after_train: false 6 | display: 20 7 | average_loss: 20 8 | base_lr: 0.0036 9 | # base_lr: 0.00125 10 | lr_policy: "step" 11 | # stepsize: 320000 12 | stepsize: 40000 13 | gamma: 1 14 | #max_iter: 160000 15 | max_iter: 120000 16 | #max_iter: 80000 17 | #max_iter: 20000 18 | #max_iter: 40000 19 | #max_iter: 100 20 | #max_iter: 40 21 | momentum: 0.9 22 | # weight_decay: 0.0002 23 | weight_decay: 0.00005 24 | random_seed: 1234568 25 | snapshot: 20000 26 | snapshot_prefix: "imagenet_8parts_gaia_th_01_skewdata_10p_stat_lan/googlenet_snapshot" 27 | solver_mode: GPU -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layers/silence_layer.cpp: -------------------------------------------------------------------------------- 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::Backward_cpu(const vector*>& top, 10 | const vector& propagate_down, const vector*>& bottom) { 11 | for (int i = 0; i < bottom.size(); ++i) { 12 | if (propagate_down[i]) { 13 | caffe_set(bottom[i]->count(), Dtype(0), 14 | bottom[i]->mutable_cpu_diff()); 15 | } 16 | } 17 | } 18 | 19 | #ifdef CPU_ONLY 20 | STUB_GPU(SilenceLayer); 21 | #endif 22 | 23 | INSTANTIATE_CLASS(SilenceLayer); 24 | REGISTER_LAYER_CLASS(Silence); 25 | 26 | } // namespace caffe 27 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/util/cudnn.cpp: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUDNN 2 | #include "caffe/util/cudnn.hpp" 3 | 4 | namespace caffe { 5 | namespace cudnn { 6 | 7 | float dataType::oneval = 1.0; 8 | float dataType::zeroval = 0.0; 9 | const void* dataType::one = 10 | static_cast(&dataType::oneval); 11 | const void* dataType::zero = 12 | static_cast(&dataType::zeroval); 13 | 14 | double dataType::oneval = 1.0; 15 | double dataType::zeroval = 0.0; 16 | const void* dataType::one = 17 | static_cast(&dataType::oneval); 18 | const void* dataType::zero = 19 | static_cast(&dataType::zeroval); 20 | 21 | } // namespace cudnn 22 | } // namespace caffe 23 | #endif 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/create_cifar10_skew.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This script converts the cifar data into leveldb format. 3 | 4 | 5 | for p in 20 40 60 80 100; do 6 | 7 | OUTPUT=examples/cifar10/5parts/skewed_${p} 8 | DATA=data/cifar10 9 | DBTYPE=lmdb 10 | 11 | echo "Creating $DBTYPE..." 12 | 13 | mkdir -p ${OUTPUT} 14 | 15 | rm -rf ${OUTPUT}/cifar10_train_lmdb.% 16 | rm -rf ${OUTPUT}/cifar10_test_lmdb.% 17 | 18 | ./build/examples/cifar10/convert_partitioned_cifar_data_skew.bin $DATA $OUTPUT $DBTYPE 5 ${p} % 19 | 20 | echo "Computing image mean..." 21 | 22 | ./build/tools/compute_image_mean -backend=$DBTYPE $OUTPUT/cifar10_train_$DBTYPE.% $OUTPUT/mean.binaryproto.% 23 | 24 | echo "Done." 25 | done 26 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/signal_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_CAFFE_UTIL_SIGNAL_HANDLER_H_ 2 | #define INCLUDE_CAFFE_UTIL_SIGNAL_HANDLER_H_ 3 | 4 | #include "caffe/proto/caffe.pb.h" 5 | #include "caffe/solver.hpp" 6 | 7 | namespace caffe { 8 | 9 | class SignalHandler { 10 | public: 11 | // Contructor. Specify what action to take when a signal is received. 12 | SignalHandler(SolverAction::Enum SIGINT_action, 13 | SolverAction::Enum SIGHUP_action); 14 | ~SignalHandler(); 15 | ActionCallback GetActionFunction(); 16 | private: 17 | SolverAction::Enum CheckForSignals() const; 18 | SolverAction::Enum SIGINT_action_; 19 | SolverAction::Enum SIGHUP_action_; 20 | }; 21 | 22 | } // namespace caffe 23 | 24 | #endif // INCLUDE_CAFFE_UTIL_SIGNAL_HANDLER_H_ 25 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/1parts/create_cifar10.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This script converts the cifar data into leveldb format. 3 | 4 | OUTPUT=examples/cifar10/1parts 5 | DATA=data/cifar10 6 | DBTYPE=lmdb 7 | 8 | for setting in shuffled skewed; 9 | do 10 | echo "Creating $DBTYPE..." 11 | 12 | mkdir -p ${OUTPUT}/${setting} 13 | rm -rf ${OUTPUT}/${setting}/cifar10_train_lmdb.% 14 | rm -rf ${OUTPUT}/${setting}/cifar10_test_lmdb.% 15 | 16 | ./build/examples/cifar10/convert_partitioned_cifar_data.bin $DATA $OUTPUT/${setting} $DBTYPE ${setting} 1 % 17 | 18 | echo "Computing image mean..." 19 | 20 | ./build/tools/compute_image_mean -backend=$DBTYPE $OUTPUT/${setting}/cifar10_train_$DBTYPE.% $OUTPUT/${setting}/mean.binaryproto.% 21 | done 22 | 23 | echo "Done." 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/create_cifar10.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This script converts the cifar data into leveldb format. 3 | 4 | OUTPUT=examples/cifar10/2parts 5 | DATA=data/cifar10 6 | DBTYPE=lmdb 7 | 8 | for setting in shuffled skewed; 9 | do 10 | echo "Creating $DBTYPE..." 11 | 12 | mkdir -p ${OUTPUT}/${setting} 13 | rm -rf ${OUTPUT}/${setting}/cifar10_train_lmdb.% 14 | rm -rf ${OUTPUT}/${setting}/cifar10_test_lmdb.% 15 | 16 | ./build/examples/cifar10/convert_partitioned_cifar_data.bin $DATA $OUTPUT/${setting} $DBTYPE ${setting} 2 % 17 | 18 | echo "Computing image mean..." 19 | 20 | ./build/tools/compute_image_mean -backend=$DBTYPE $OUTPUT/${setting}/cifar10_train_$DBTYPE.% $OUTPUT/${setting}/mean.binaryproto.% 21 | done 22 | 23 | echo "Done." 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/create_cifar10.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This script converts the cifar data into leveldb format. 3 | 4 | OUTPUT=examples/cifar10/5parts 5 | DATA=data/cifar10 6 | DBTYPE=lmdb 7 | 8 | for setting in shuffled skewed; 9 | do 10 | echo "Creating $DBTYPE..." 11 | 12 | mkdir -p ${OUTPUT}/${setting} 13 | rm -rf ${OUTPUT}/${setting}/cifar10_train_lmdb.% 14 | rm -rf ${OUTPUT}/${setting}/cifar10_test_lmdb.% 15 | 16 | ./build/examples/cifar10/convert_partitioned_cifar_data.bin $DATA $OUTPUT/${setting} $DBTYPE ${setting} 5 % 17 | 18 | echo "Computing image mean..." 19 | 20 | ./build/tools/compute_image_mean -backend=$DBTYPE $OUTPUT/${setting}/cifar10_train_$DBTYPE.% $OUTPUT/${setting}/mean.binaryproto.% 21 | done 22 | 23 | echo "Done." 24 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/util/db_leveldb.cpp: -------------------------------------------------------------------------------- 1 | #ifdef USE_LEVELDB 2 | #include "caffe/util/db_leveldb.hpp" 3 | 4 | #include 5 | 6 | namespace caffe { namespace db { 7 | 8 | void LevelDB::Open(const string& source, Mode mode) { 9 | leveldb::Options options; 10 | options.block_size = 65536; 11 | options.write_buffer_size = 268435456; 12 | options.max_open_files = 100; 13 | options.error_if_exists = mode == NEW; 14 | options.create_if_missing = mode != READ; 15 | leveldb::Status status = leveldb::DB::Open(options, source, &db_); 16 | CHECK(status.ok()) << "Failed to open leveldb " << source 17 | << std::endl << status.ToString(); 18 | LOG(INFO) << "Opened leveldb " << source; 19 | } 20 | 21 | } // namespace db 22 | } // namespace caffe 23 | #endif // USE_LEVELDB 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_brnlenet1: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_brnlenet2: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_inception: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_brnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_inceptionbrn: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_inceptionbrn1: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_inceptionbrn2: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_googlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=10000000000 4 | mm_warning_level=3 5 | layers_per_table=1 6 | batches_per_clock=1 7 | enable_gaia=1 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | acc_conflict_update=0 25 | conf_ratio_to_lower_update_threshold=0 26 | lower_update_threshold=0 27 | lower_update_table_limit=0 28 | model_traveling_freq=0 29 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/create_cifar10.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This script converts the cifar data into leveldb format. 3 | 4 | OUTPUT=examples/cifar10/10parts 5 | DATA=data/cifar10 6 | DBTYPE=lmdb 7 | 8 | #for setting in shuffled skewed; 9 | for setting in skewed_80; 10 | do 11 | echo "Creating $DBTYPE..." 12 | 13 | mkdir -p ${OUTPUT}/${setting} 14 | rm -rf ${OUTPUT}/${setting}/cifar10_train_lmdb.% 15 | rm -rf ${OUTPUT}/${setting}/cifar10_test_lmdb.% 16 | 17 | ${GAIA_PATH}/./build/examples/cifar10/convert_partitioned_cifar_data.bin $DATA $OUTPUT/${setting} $DBTYPE ${setting} 10 % 18 | 19 | echo "Computing image mean..." 20 | 21 | ${GAIA_PATH}/./build/tools/compute_image_mean -backend=$DBTYPE $OUTPUT/${setting}/cifar10_train_$DBTYPE.% $OUTPUT/${setting}/mean.binaryproto.% 22 | done 23 | 24 | echo "Done." 25 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/scripts/make-layers.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from string import maketrans 4 | 5 | num_layers = 64 6 | for i in range(num_layers): 7 | print('layer {') 8 | print(' name: "fc%i"' % (i + 1)) 9 | print(' type: "InnerProduct"') 10 | print(' bottom: "fc%i"' % i) 11 | print(' top: "fc%i"' % (i + 1)) 12 | print(' param {') 13 | print(' lr_mult: 1') 14 | print(' decay_mult: 1') 15 | print(' }') 16 | print(' param {') 17 | print(' lr_mult: 2') 18 | print(' decay_mult: 0') 19 | print(' }') 20 | print(' inner_product_param {') 21 | print(' num_output: 10000') 22 | # print(' weight_filler {') 23 | # print(' type: "gaussian"') 24 | # print(' std: 0.005') 25 | # print(' }') 26 | # print(' bias_filler {') 27 | # print(' type: "constant"') 28 | # print(' value: 0.1') 29 | # print(' }') 30 | print(' }') 31 | print('}') 32 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layers/loss_layer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/loss_layer.hpp" 4 | 5 | namespace caffe { 6 | 7 | template 8 | void LossLayer::LayerSetUp( 9 | const vector*>& bottom, const vector*>& top) { 10 | // LossLayers have a non-zero (1) loss by default. 11 | if (this->layer_param_.loss_weight_size() == 0) { 12 | this->layer_param_.add_loss_weight(Dtype(1)); 13 | } 14 | } 15 | 16 | template 17 | void LossLayer::Reshape( 18 | const vector*>& bottom, const vector*>& top) { 19 | CHECK_EQ(bottom[0]->num(), bottom[1]->num()) 20 | << "The data and label should have the same number."; 21 | vector loss_shape(0); // Loss layers output a scalar; 0 axes. 22 | top[0]->Reshape(loss_shape); 23 | } 24 | 25 | INSTANTIATE_CLASS(LossLayer); 26 | 27 | } // namespace caffe 28 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/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 | <<>>( 19 | N, g, h, momentum, local_rate); 20 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 21 | } 22 | template void sgd_update_gpu(int, float*, float*, float, float); 23 | template void sgd_update_gpu(int, double*, double*, double, double); 24 | 25 | } // namespace caffe 26 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 by Anonymous Institution. 2 | 3 | import os 4 | 5 | env = DefaultEnvironment() 6 | env['build_debug'] = ARGUMENTS.get('debug', '0') 7 | 8 | build_variants = COMMAND_LINE_TARGETS 9 | if len(build_variants) == 0: 10 | build_variants = ['build'] 11 | 12 | # Make a phony target to time stamp the last build success 13 | def PhonyTarget(target, source, action): 14 | env.Append(BUILDERS = { 'phony' : Builder(action = action) }) 15 | AlwaysBuild(env.phony(target = target, source = source)) 16 | 17 | def write_build_info(target, source, env): 18 | build_options = 'scons build=%s' % env['build_debug'] 19 | os.system('echo %s > build/last-build-info' % build_options) 20 | os.system('date >> build/last-build-info') 21 | 22 | if 'build' in build_variants: 23 | builds = SConscript('SConscript', variant_dir='build', duplicate=1) 24 | PhonyTarget('build/write-build-info', builds, write_build_info) 25 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/ps_config_alexnet: -------------------------------------------------------------------------------- 1 | num_channels=1 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=10 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=1 31 | dgc_epoch_size=1000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/ps_config_lenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=10 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=1 31 | dgc_epoch_size=1000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/10parts/ps_config_resnet20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_lenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=1 8 | num_dc=2 9 | mirror_update_threshold=0.50 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.50 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=1 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_alexnet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_bnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=1 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_googlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_lenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_resnet20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_resnet20e: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=2000 30 | enable_dgc=0 31 | dgc_epoch_size=4000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_resnet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=9000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=1 8 | num_dc=2 9 | mirror_update_threshold=0.005 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.005 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=1 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_resnetbrnn20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_googlenete: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.50 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.50 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=2000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/examples/femnist/10parts/ps_config_resnet20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=10 9 | mirror_update_threshold=0.90 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.90 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/test/test_protobuf.cpp: -------------------------------------------------------------------------------- 1 | // This is simply a script that tries serializing protocol buffer in text 2 | // format. Nothing special here and no actual code is being tested. 3 | #include 4 | 5 | #include "google/protobuf/text_format.h" 6 | #include "gtest/gtest.h" 7 | 8 | #include "caffe/proto/caffe.pb.h" 9 | 10 | #include "caffe/test/test_caffe_main.hpp" 11 | 12 | namespace caffe { 13 | 14 | class ProtoTest : public ::testing::Test {}; 15 | 16 | TEST_F(ProtoTest, TestSerialization) { 17 | LayerParameter param; 18 | param.set_name("test"); 19 | param.set_type("Test"); 20 | std::cout << "Printing in binary format." << std::endl; 21 | std::cout << param.SerializeAsString() << std::endl; 22 | std::cout << "Printing in text format." << std::endl; 23 | std::string str; 24 | google::protobuf::TextFormat::PrintToString(param, &str); 25 | std::cout << str << std::endl; 26 | EXPECT_TRUE(true); 27 | } 28 | 29 | } // namespace caffe 30 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/insert_splits.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _CAFFE_UTIL_INSERT_SPLITS_HPP_ 2 | #define _CAFFE_UTIL_INSERT_SPLITS_HPP_ 3 | 4 | #include 5 | 6 | #include "caffe/proto/caffe.pb.h" 7 | 8 | namespace caffe { 9 | 10 | // Copy NetParameters with SplitLayers added to replace any shared bottom 11 | // blobs with unique bottom blobs provided by the SplitLayer. 12 | void InsertSplits(const NetParameter& param, NetParameter* param_split); 13 | 14 | void ConfigureSplitLayer(const string& layer_name, const string& blob_name, 15 | const int blob_idx, const int split_count, const float loss_weight, 16 | LayerParameter* split_layer_param); 17 | 18 | string SplitLayerName(const string& layer_name, const string& blob_name, 19 | const int blob_idx); 20 | 21 | string SplitBlobName(const string& layer_name, const string& blob_name, 22 | const int blob_idx, const int split_idx); 23 | 24 | } // namespace caffe 25 | 26 | #endif // CAFFE_UTIL_INSERT_SPLITS_HPP_ 27 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/Layer.m: -------------------------------------------------------------------------------- 1 | classdef Layer < handle 2 | % Wrapper class of caffe::Layer in matlab 3 | 4 | properties (Access = private) 5 | hLayer_self 6 | attributes 7 | % attributes fields: 8 | % hBlob_blobs 9 | end 10 | properties (SetAccess = private) 11 | params 12 | end 13 | 14 | methods 15 | function self = Layer(hLayer_layer) 16 | CHECK(is_valid_handle(hLayer_layer), 'invalid Layer handle'); 17 | 18 | % setup self handle and attributes 19 | self.hLayer_self = hLayer_layer; 20 | self.attributes = caffe_('layer_get_attr', self.hLayer_self); 21 | 22 | % setup weights 23 | self.params = caffe.Blob.empty(); 24 | for n = 1:length(self.attributes.hBlob_blobs) 25 | self.params(n) = caffe.Blob(self.attributes.hBlob_blobs(n)); 26 | end 27 | end 28 | function layer_type = type(self) 29 | layer_type = caffe_('layer_get_type', self.hLayer_self); 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/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 | <<>>( 21 | N, g, h, delta, local_rate); 22 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 23 | } 24 | template void adagrad_update_gpu(int, float*, float*, float, float); 25 | template void adagrad_update_gpu(int, double*, double*, double, double); 26 | 27 | } // namespace caffe 28 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/util/db.cpp: -------------------------------------------------------------------------------- 1 | #include "caffe/util/db.hpp" 2 | #include "caffe/util/db_leveldb.hpp" 3 | #include "caffe/util/db_lmdb.hpp" 4 | 5 | #include 6 | 7 | namespace caffe { namespace db { 8 | 9 | DB* GetDB(DataParameter::DB backend) { 10 | switch (backend) { 11 | #ifdef USE_LEVELDB 12 | case DataParameter_DB_LEVELDB: 13 | return new LevelDB(); 14 | #endif // USE_LEVELDB 15 | #ifdef USE_LMDB 16 | case DataParameter_DB_LMDB: 17 | return new LMDB(); 18 | #endif // USE_LMDB 19 | default: 20 | LOG(FATAL) << "Unknown database backend"; 21 | return NULL; 22 | } 23 | } 24 | 25 | DB* GetDB(const string& backend) { 26 | #ifdef USE_LEVELDB 27 | if (backend == "leveldb") { 28 | return new LevelDB(); 29 | } 30 | #endif // USE_LEVELDB 31 | #ifdef USE_LMDB 32 | if (backend == "lmdb") { 33 | return new LMDB(); 34 | } 35 | #endif // USE_LMDB 36 | LOG(FATAL) << "Unknown database backend"; 37 | return NULL; 38 | } 39 | 40 | } // namespace db 41 | } // namespace caffe 42 | -------------------------------------------------------------------------------- /apps/caffe/examples/casia/4parts/ps_config_face: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=6000 30 | enable_dgc=1 31 | dgc_epoch_size=15084 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/1parts/ps_config_gnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=1 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_bnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=1 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_gnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.20 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.20 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=50 30 | enable_dgc=0 31 | dgc_epoch_size=2000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_gnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_brnlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=1 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_resnet20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=2000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_resnetbrn20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=10 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/ps_config_resnetgn20: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=5 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/5parts/ps_config_googlenetv2: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=9000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=1 8 | num_dc=5 9 | mirror_update_threshold=0.20 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.20 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=50 30 | enable_dgc=0 31 | dgc_epoch_size=9000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_resnet10: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=9000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=4 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=1000 30 | enable_dgc=1 31 | dgc_epoch_size=20000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/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: GPU 27 | -------------------------------------------------------------------------------- /apps/caffe/examples/geoanimal/13parts/ps_config_googlenetv2: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=9000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=13 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=1000 30 | enable_dgc=0 31 | dgc_epoch_size=10000 32 | apply_change_to_local_model=1 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/ps_config_googlenetv2: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=9000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=1000 30 | enable_dgc=1 31 | dgc_epoch_size=10000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched= 35 | gaia_threshold_iter=500 36 | gradient_clip_threshold=0 37 | -------------------------------------------------------------------------------- /apps/caffe/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: GPU 27 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/layers/neuron_layer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_NEURON_LAYER_HPP_ 2 | #define CAFFE_NEURON_LAYER_HPP_ 3 | 4 | #include 5 | 6 | #include "caffe/blob.hpp" 7 | #include "caffe/layer.hpp" 8 | #include "caffe/proto/caffe.pb.h" 9 | 10 | namespace caffe { 11 | 12 | /** 13 | * @brief An interface for layers that take one blob as input (@f$ x @f$) 14 | * and produce one equally-sized blob as output (@f$ y @f$), where 15 | * each element of the output depends only on the corresponding input 16 | * element. 17 | */ 18 | template 19 | class NeuronLayer : public Layer { 20 | public: 21 | explicit NeuronLayer(const LayerParameter& param) 22 | : Layer(param) {} 23 | virtual void Reshape(const vector*>& bottom, 24 | const vector*>& top); 25 | 26 | virtual inline int ExactNumBottomBlobs() const { return 1; } 27 | virtual inline int ExactNumTopBlobs() const { return 1; } 28 | }; 29 | 30 | } // namespace caffe 31 | 32 | #endif // CAFFE_NEURON_LAYER_HPP_ 33 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layers/threshold_layer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/threshold_layer.hpp" 4 | 5 | namespace caffe { 6 | 7 | template 8 | void ThresholdLayer::LayerSetUp(const vector*>& bottom, 9 | const vector*>& top) { 10 | NeuronLayer::LayerSetUp(bottom, top); 11 | threshold_ = this->layer_param_.threshold_param().threshold(); 12 | } 13 | 14 | template 15 | void ThresholdLayer::Forward_cpu(const vector*>& bottom, 16 | const vector*>& top) { 17 | const Dtype* bottom_data = bottom[0]->cpu_data(); 18 | Dtype* top_data = top[0]->mutable_cpu_data(); 19 | const int count = bottom[0]->count(); 20 | for (int i = 0; i < count; ++i) { 21 | top_data[i] = (bottom_data[i] > threshold_) ? Dtype(1) : Dtype(0); 22 | } 23 | } 24 | 25 | #ifdef CPU_ONLY 26 | STUB_GPU_FORWARD(ThresholdLayer, Forward); 27 | #endif 28 | 29 | INSTANTIATE_CLASS(ThresholdLayer); 30 | REGISTER_LAYER_CLASS(Threshold); 31 | 32 | } // namespace caffe 33 | -------------------------------------------------------------------------------- /apps/caffe/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 | <<>>( 21 | N, g, h, momentum, local_rate); 22 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 23 | } 24 | template void nesterov_update_gpu(int, float*, float*, float, float); 25 | template void nesterov_update_gpu(int, double*, double*, double, 26 | double); 27 | 28 | } // namespace caffe 29 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_alexnet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=0 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=1 29 | fedavg_local_iter=2000 30 | enable_dgc=0 31 | dgc_epoch_size=8000 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=1 34 | gaia_threshold_sched=0.30,0.15,0.10,0.05,0.05,0.10,0.10,0.05,0.05,0.05,0.05,0.10,0.10,0.15,0.15,0.20,0.25,0.30 35 | gaia_threshold_iter=500 36 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/ps_config_googlenet: -------------------------------------------------------------------------------- 1 | num_channels=4 2 | slack=0 3 | gpu_memory_capacity=8000000000 4 | mm_warning_level=3 5 | layers_per_table=5 6 | batches_per_clock=1 7 | enable_gaia=1 8 | num_dc=2 9 | mirror_update_threshold=0.01 10 | merge_local_update=1 11 | aggr_mirror_update_table_group=0 12 | aggr_mirror_update_threshold=0.01 13 | enable_mirror_reorder=0 14 | wan_bandwidth_limit=16.76 15 | mirror_update_lower_bound=0.005 16 | iters_reach_lower_bound=-1 17 | slack_table_limit=-1 18 | enable_overlay_network=0 19 | enable_olnw_multiple_routers=0 20 | enable_threshold_by_bw=0 21 | flush_mirror_update_per_iter=0 22 | local_model_only=0 23 | mirror_update_value_threshold=0 24 | lower_update_threshold=0 25 | lower_update_table_limit=0 26 | model_traveling_freq=0 27 | debug=0 28 | enable_fedavg=0 29 | fedavg_local_iter=4000 30 | enable_dgc=0 31 | dgc_epoch_size=500 32 | apply_change_to_local_model=0 33 | disable_dgc_momemtum_mask=0 34 | gaia_threshold_sched=0.30,0.15,0.10,0.05,0.05,0.10,0.10,0.05,0.05,0.05,0.05,0.10,0.10,0.15,0.15,0.20,0.25,0.30 35 | gaia_threshold_iter=500 36 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/private/is_valid_handle.m: -------------------------------------------------------------------------------- 1 | function valid = is_valid_handle(hObj) 2 | % valid = is_valid_handle(hObj) or is_valid_handle('get_new_init_key') 3 | % Check if a handle is valid (has the right data type and init_key matches) 4 | % Use is_valid_handle('get_new_init_key') to get new init_key from C++; 5 | 6 | % a handle is a struct array with the following fields 7 | % (uint64) ptr : the pointer to the C++ object 8 | % (double) init_key : caffe initialization key 9 | 10 | persistent init_key; 11 | if isempty(init_key) 12 | init_key = caffe_('get_init_key'); 13 | end 14 | 15 | % is_valid_handle('get_new_init_key') to get new init_key from C++; 16 | if ischar(hObj) && strcmp(hObj, 'get_new_init_key') 17 | init_key = caffe_('get_init_key'); 18 | return 19 | else 20 | % check whether data types are correct and init_key matches 21 | valid = isstruct(hObj) ... 22 | && isscalar(hObj.ptr) && isa(hObj.ptr, 'uint64') ... 23 | && isscalar(hObj.init_key) && isa(hObj.init_key, 'double') ... 24 | && hObj.init_key == init_key; 25 | end 26 | 27 | end 28 | -------------------------------------------------------------------------------- /apps/caffe/get_cifar10_results.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | net=${1} 4 | p=${2} 5 | folder=${3} 6 | 7 | echo "BSP" 8 | 9 | for data in shuffledata skewdata; do 10 | python get_cifar_result.py ${p} ${folder}/cifar10_${net}_${p}parts_bsp_${data}/output.txt 11 | done 12 | 13 | echo "Gaia" 14 | 15 | for data in shuffledata skeweddata; do 16 | for th in 0.02 0.05 0.10 0.20 0.30; do 17 | python get_cifar_result.py ${p} ${folder}/cifar10_${net}_${p}parts_gaia_th_${th}_lm_1_${data}/output.txt 18 | done 19 | echo "---" 20 | done 21 | 22 | echo "FedAvg" 23 | 24 | for data in shuffledata skeweddata; do 25 | for iter in 5 10 50 200 1000; do 26 | python get_cifar_result.py ${p} ${folder}/cifar10_${net}_${p}parts_fedavg_iter_${iter}_${data}/output.txt 27 | done 28 | echo "---" 29 | done 30 | 31 | echo "DGC" 32 | 33 | for data in shuffledata skeweddata; do 34 | for e in 1000 2000 8000; do 35 | python get_cifar_result.py ${p} ${folder}/cifar10_${net}_${p}parts_dgc_epoch_${e}_lm_0_dmm_0_${data}/output.txt 36 | done 37 | echo "---" 38 | done 39 | 40 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/blocking_queue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_UTIL_BLOCKING_QUEUE_HPP_ 2 | #define CAFFE_UTIL_BLOCKING_QUEUE_HPP_ 3 | 4 | #include 5 | #include 6 | 7 | namespace caffe { 8 | 9 | template 10 | class BlockingQueue { 11 | public: 12 | explicit BlockingQueue(); 13 | 14 | void push(const T& t); 15 | 16 | bool try_pop(T* t); 17 | 18 | // This logs a message if the threads needs to be blocked 19 | // useful for detecting e.g. when data feeding is too slow 20 | T pop(const string& log_on_wait = ""); 21 | 22 | bool try_peek(T* t); 23 | 24 | // Return element without removing it 25 | T peek(); 26 | 27 | size_t size() const; 28 | 29 | protected: 30 | /** 31 | Move synchronization fields out instead of including boost/thread.hpp 32 | to avoid a boost/NVCC issues (#1009, #1010) on OSX. Also fails on 33 | Linux CUDA 7.0.18. 34 | */ 35 | class sync; 36 | 37 | std::queue queue_; 38 | shared_ptr sync_; 39 | 40 | DISABLE_COPY_AND_ASSIGN(BlockingQueue); 41 | }; 42 | 43 | } // namespace caffe 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /apps/caffe/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: 200 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: GPU 28 | -------------------------------------------------------------------------------- /apps/caffe/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: GPU 28 | -------------------------------------------------------------------------------- /apps/caffe/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: GPU 28 | -------------------------------------------------------------------------------- /apps/caffe/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<<>>( 24 | count, threshold_, bottom_data, top_data); 25 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 26 | } 27 | 28 | 29 | INSTANTIATE_LAYER_GPU_FORWARD(ThresholdLayer); 30 | 31 | 32 | } // namespace caffe 33 | -------------------------------------------------------------------------------- /apps/caffe/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: GPU 29 | -------------------------------------------------------------------------------- /apps/caffe/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 | <<>>( 21 | N, g, h, rms_decay, delta, local_rate); 22 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 23 | } 24 | template void rmsprop_update_gpu(int, float*, float*, float, float, 25 | float); 26 | template void rmsprop_update_gpu(int, double*, double*, double, double, 27 | double); 28 | 29 | } // namespace caffe 30 | -------------------------------------------------------------------------------- /apps/caffe/scripts/duplicate.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from string import maketrans 4 | 5 | file_name = sys.argv[1] 6 | num_dups = int(sys.argv[2]) 7 | intab = '%' 8 | if len(sys.argv) > 3: 9 | intab = sys.argv[3] 10 | pattern = '' 11 | if len(sys.argv) > 4: 12 | pattern = sys.argv[4] 13 | 14 | template_file = '%s.template' % (file_name) 15 | template_fd = open(template_file, 'r') 16 | 17 | output_files = [] 18 | output_fds = [] 19 | for i in range(num_dups): 20 | output_file = '%s.%i' % (file_name, i) 21 | if pattern != '': 22 | output_file = pattern % i 23 | output_files.append(output_file) 24 | output_fds.append(open(output_file, 'w')) 25 | 26 | for line in template_fd: 27 | for i in range(num_dups): 28 | outtab = str(i) 29 | # trantab = maketrans(intab, outtab) 30 | # print line.translate(trantab) 31 | # output_fds[i].write(line.translate(trantab)) 32 | output_fds[i].write(line.replace(intab, outtab)) 33 | 34 | template_fd.close() 35 | for i in range(num_dups): 36 | output_fds[i].close() 37 | 38 | for output_file in output_files: 39 | os.system('chmod a+x %s' % output_file) 40 | -------------------------------------------------------------------------------- /apps/caffe/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: GPU 29 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/train_caffenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/8parts/caffenet_train_val.prototxt 8 6 | python scripts/duplicate.py examples/imagenet/8parts/caffenet_solver.prototxt 8 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/8parts/train_caffenet.sh $1/. 16 | cp examples/imagenet/8parts/caffenet_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/caffenet_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_caffenet $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/caffenet_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_caffenet --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/train_caffenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/8parts/caffenet_train_val.prototxt 8 6 | python scripts/duplicate.py examples/imagenet/8parts/caffenet_solver.prototxt 8 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/8parts/train_caffenet.sh $1/. 16 | cp examples/imagenet/8parts/caffenet_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/caffenet_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_caffenet $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/caffenet_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_caffenet --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/train_inception.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/8parts/inception_train_val.prototxt 8 6 | python scripts/duplicate.py examples/imagenet/8parts/inception_solver.prototxt 8 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/8parts/train_inception.sh $1/. 16 | cp examples/imagenet/8parts/inception_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/inception_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_inception $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/inception_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_inception --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/scripts/summarize-log.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from datetime import datetime, timedelta 4 | 5 | input_file = sys.argv[1] 6 | num_workers = 8 7 | if len(sys.argv) > 2: 8 | num_workers = int(sys.argv[2]) 9 | 10 | input_fd = open(input_file, 'r') 11 | times = [] 12 | clocks = [] 13 | losses = [] 14 | for line in input_fd: 15 | strs = line.split() 16 | if not len(strs) == 9 and not len(strs) == 10: 17 | continue 18 | if not strs[6] == 'loss': 19 | continue 20 | # times.append(float(strs[5][:-1])) 21 | time_tuple = datetime.strptime(strs[1], "%H:%M:%S.%f") 22 | times.append(time_tuple.hour * 3600 + time_tuple.minute * 60 + time_tuple.second) 23 | clocks.append(int(strs[5][:-1])) 24 | losses.append(float(strs[8])) 25 | 26 | n = len(losses) 27 | count = 0 28 | for i in range(n): 29 | if times[i] < times[0]: 30 | times[i] = times[i] + 86400 31 | # print '%i,%i,%f'% (clocks[i], times[i] - times[0], losses[i]) 32 | count = count + losses[i] 33 | if ((i + 1) % num_workers == 0): 34 | print '%i,%i,%f'% (clocks[i], times[i] - times[num_workers - 1], count / num_workers) 35 | count = 0 36 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/train_inception.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/8parts/inception_train_val.prototxt 8 6 | python scripts/duplicate.py examples/imagenet/8parts/inception_solver.prototxt 8 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/8parts/train_inception.sh $1/. 16 | cp examples/imagenet/8parts/inception_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/inception_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_inception $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/inception_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_inception --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/train_googlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/11parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/11parts/googlenet_train_val.prototxt 11 6 | python scripts/duplicate.py examples/imagenet/11parts/googlenet_solver.prototxt 11 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/11parts/train_googlenet.sh $1/. 16 | cp examples/imagenet/11parts/googlenet_train_val.prototxt.template $1/. 17 | cp examples/imagenet/11parts/googlenet_solver.prototxt.template $1/. 18 | cp examples/imagenet/11parts/machinefile $1/. 19 | cp examples/imagenet/11parts/ps_config_googlenet $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/11parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/11parts/googlenet_solver.prototxt --ps_config=examples/imagenet/11parts/ps_config_googlenet --machinefile=examples/imagenet/11parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /scripts/install-caffe-deps-ubuntu14.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update 2 | sudo apt-get install -y --force-yes libatlas-base-dev 3 | sudo apt-get install -y --force-yes libopencv-dev 4 | sudo apt-get install -y --force-yes protobuf-compiler 5 | sudo apt-get install -y --force-yes libprotobuf-dev 6 | sudo apt-get install -y --force-yes libgoogle-glog-dev 7 | sudo apt-get install -y --force-yes libgflags-dev 8 | sudo apt-get install -y --force-yes libhdf5-dev 9 | sudo apt-get install -y --force-yes libleveldb-dev 10 | sudo apt-get install -y --force-yes libsnappy-dev 11 | sudo apt-get install -y --force-yes liblmdb-dev 12 | sudo apt-get install -y --force-yes libpython-dev 13 | sudo apt-get install -y --force-yes libboost-python-dev 14 | sudo apt-get install -y --force-yes libboost-filesystem-dev 15 | sudo apt-get install -y --force-yes cython 16 | sudo apt-get install -y --force-yes python-numpy 17 | sudo apt-get install -y --force-yes python-protobuf 18 | sudo apt-get install -y --force-yes python-skimage 19 | sudo apt-get install -y --force-yes python-h5py 20 | sudo apt-get install -y --force-yes python-matplotlib 21 | sudo apt-get install -y --force-yes openjdk-7-jre 22 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/11parts/train_inception_v3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/8parts/inception_v3_train_val.prototxt 8 6 | python scripts/duplicate.py examples/imagenet/8parts/inception_v3_solver.prototxt 8 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/8parts/train_inception_v3.sh $1/. 16 | cp examples/imagenet/8parts/inception_v3_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/inception_v3_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_inception_v3 $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/inception_v3_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_inception_v3 --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/train_inception_v3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | python scripts/duplicate.py examples/imagenet/8parts/inception_v3_train_val.prototxt 8 6 | python scripts/duplicate.py examples/imagenet/8parts/inception_v3_solver.prototxt 8 7 | 8 | LOG=output.txt 9 | 10 | if [ "$#" -eq 1 ]; then 11 | mkdir $1 12 | pwd > $1/pwd 13 | git status > $1/git-status 14 | git diff > $1/git-diff 15 | cp examples/imagenet/8parts/train_inception_v3.sh $1/. 16 | cp examples/imagenet/8parts/inception_v3_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/inception_v3_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_inception_v3 $1/. 20 | LOG=$1/output.txt 21 | fi 22 | 23 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/inception_v3_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_inception_v3 --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n" 2>&1 | tee ${LOG} 24 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/inception_solver.prototxt.template: -------------------------------------------------------------------------------- 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/2parts/inception_train_val.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: 50 9 | # Carry out testing every 500 training iterations. 10 | test_interval: 1000 11 | test_initialization: false 12 | snapshot_after_train: false 13 | # The base learning rate, momentum and the weight decay of the network. 14 | base_lr: 0.001 15 | momentum: 0.9 16 | weight_decay: 0.004 17 | # The learning rate policy 18 | lr_policy: "fixed" 19 | # Display every 100 iterations 20 | display: 100 21 | # The maximum number of iterations 22 | #max_iter: 40000000 23 | max_iter: 65000 24 | # snapshot intermediate results 25 | snapshot: 5000 26 | # snapshot_format: HDF5 27 | snapshot_prefix: "cifar10_inception_2parts_fedavg_iter_4000_skeweddata_stat_lan/cifar_snapshot" 28 | # solver mode: CPU or GPU 29 | solver_mode: GPU 30 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/src/caffe/layers/reshape_layer.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "caffe/layers/reshape_layer.hpp" 4 | 5 | namespace caffe { 6 | 7 | template 8 | void ReshapeLayer::Forward_gpu(const vector*>& bottom, 9 | const vector*>& top) { 10 | CHECK_EQ(bottom.size(), 1); 11 | CHECK_EQ(top.size(), 1); 12 | CHECK_EQ(bottom[0]->count(), top[0]->count()); 13 | /* XXX: copy instead of share, because the bottom data could be released */ 14 | int count_ = bottom[0]->count(); 15 | caffe_copy(count_, bottom[0]->gpu_data(), top[0]->mutable_gpu_data()); 16 | } 17 | 18 | template 19 | void ReshapeLayer::Backward_gpu(const vector*>& top, 20 | const vector& propagate_down, const vector*>& bottom) { 21 | CHECK_EQ(bottom.size(), 1); 22 | CHECK_EQ(top.size(), 1); 23 | CHECK_EQ(bottom[0]->count(), top[0]->count()); 24 | if (!propagate_down[0]) { 25 | return; 26 | } 27 | int count_ = bottom[0]->count(); 28 | caffe_copy(count_, top[0]->gpu_diff(), bottom[0]->mutable_gpu_diff()); 29 | } 30 | 31 | 32 | INSTANTIATE_LAYER_GPU_FUNCS(ReshapeLayer); 33 | 34 | } // namespace caffe 35 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/inceptionbrn1_solver.prototxt.template: -------------------------------------------------------------------------------- 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/2parts/inceptionbrn1_train_val.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: 50 9 | # Carry out testing every 500 training iterations. 10 | test_interval: 1000 11 | test_initialization: false 12 | snapshot_after_train: false 13 | # The base learning rate, momentum and the weight decay of the network. 14 | base_lr: 0.001 15 | momentum: 0.9 16 | weight_decay: 0.004 17 | # The learning rate policy 18 | lr_policy: "fixed" 19 | # Display every 100 iterations 20 | display: 100 21 | # The maximum number of iterations 22 | #max_iter: 40000000 23 | max_iter: 65000 24 | # snapshot intermediate results 25 | snapshot: 5000 26 | # snapshot_format: HDF5 27 | snapshot_prefix: "cifar10_inceptionbrn_2parts_bsp_s_5000_rs_20000_ds_20000_r_3_d_5_e_0.001_shuffledata_stat_lan/cifar_snapshot" 28 | # solver mode: CPU or GPU 29 | solver_mode: GPU 30 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/inceptionbrn_solver.prototxt.template: -------------------------------------------------------------------------------- 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/2parts/inceptionbrn_train_val.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: 50 9 | # Carry out testing every 500 training iterations. 10 | test_interval: 1000 11 | test_initialization: false 12 | snapshot_after_train: false 13 | # The base learning rate, momentum and the weight decay of the network. 14 | base_lr: 0.001 15 | momentum: 0.9 16 | weight_decay: 0.004 17 | # The learning rate policy 18 | lr_policy: "fixed" 19 | # Display every 100 iterations 20 | display: 100 21 | # The maximum number of iterations 22 | #max_iter: 40000000 23 | max_iter: 65000 24 | # snapshot intermediate results 25 | snapshot: 5000 26 | # snapshot_format: HDF5 27 | snapshot_prefix: "cifar10_inceptionbrn_2parts_bsp_s_5000_rs_20000_ds_20000_r_4_d_6_m_0.99_shuffledata_stat_lan/cifar_snapshot" 28 | # solver mode: CPU or GPU 29 | solver_mode: GPU 30 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/2parts/inceptionbrn2_solver.prototxt.template: -------------------------------------------------------------------------------- 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/2parts/inceptionbrn2_train_val.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: 50 9 | # Carry out testing every 500 training iterations. 10 | test_interval: 1000 11 | test_initialization: false 12 | snapshot_after_train: false 13 | # The base learning rate, momentum and the weight decay of the network. 14 | base_lr: 0.001 15 | momentum: 0.9 16 | weight_decay: 0.004 17 | # The learning rate policy 18 | lr_policy: "fixed" 19 | # Display every 100 iterations 20 | display: 100 21 | # The maximum number of iterations 22 | #max_iter: 40000000 23 | max_iter: 65000 24 | # snapshot intermediate results 25 | snapshot: 5000 26 | # snapshot_format: HDF5 27 | snapshot_prefix: "cifar10_inceptionbrn_2parts_bsp_s_5000_rs_20000_ds_20000_r_3_d_5_e_0.0001_shuffledata_stat_lan/cifar_snapshot" 28 | # solver mode: CPU or GPU 29 | solver_mode: GPU 30 | random_seed: 0 -------------------------------------------------------------------------------- /apps/caffe/scripts/copy_notebook.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Takes as arguments: 4 | 1. the path to a JSON file (such as an IPython notebook). 5 | 2. the path to output file 6 | 7 | If 'metadata' dict in the JSON file contains 'include_in_docs': true, 8 | then copies the file to output file, appending the 'metadata' property 9 | as YAML front-matter, adding the field 'category' with value 'notebook'. 10 | """ 11 | import os 12 | import sys 13 | import json 14 | 15 | filename = sys.argv[1] 16 | output_filename = sys.argv[2] 17 | content = json.load(open(filename)) 18 | 19 | if 'include_in_docs' in content['metadata'] and content['metadata']['include_in_docs']: 20 | yaml_frontmatter = ['---'] 21 | for key, val in content['metadata'].iteritems(): 22 | if key == 'example_name': 23 | key = 'title' 24 | if val == '': 25 | val = os.path.basename(filename) 26 | yaml_frontmatter.append('{}: {}'.format(key, val)) 27 | yaml_frontmatter += ['category: notebook'] 28 | yaml_frontmatter += ['original_path: ' + filename] 29 | 30 | with open(output_filename, 'w') as fo: 31 | fo.write('\n'.join(yaml_frontmatter + ['---']) + '\n') 32 | fo.write(open(filename).read()) 33 | -------------------------------------------------------------------------------- /apps/caffe/scripts/summarize-loss.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from datetime import datetime, timedelta 4 | 5 | input_file = sys.argv[1] 6 | num_workers = 8 7 | pdsh = 0 8 | if len(sys.argv) > 2: 9 | num_workers = int(sys.argv[2]) 10 | if len(sys.argv) > 3: 11 | pdsh = int(sys.argv[3]) 12 | 13 | input_fd = open(input_file, 'r') 14 | times = [] 15 | clocks = [] 16 | losses = [] 17 | for line in input_fd: 18 | strs = line.split() 19 | if not len(strs) == 9 + pdsh and not len(strs) == 10 + pdsh: 20 | continue 21 | if not strs[6 + pdsh] == 'loss': 22 | continue 23 | # times.append(float(strs[5][:-1])) 24 | time_tuple = datetime.strptime(strs[1 + pdsh], "%H:%M:%S.%f") 25 | times.append(time_tuple.hour * 3600 + time_tuple.minute * 60 + time_tuple.second) 26 | clocks.append(int(strs[5 + pdsh][:-1])) 27 | losses.append(float(strs[8 + pdsh])) 28 | 29 | n = len(losses) 30 | count = 0 31 | for i in range(n): 32 | if times[i] < times[0]: 33 | times[i] = times[i] + 86400 34 | # print '%i,%i,%f'% (clocks[i], times[i] - times[0], losses[i]) 35 | count = count + losses[i] 36 | if ((i + 1) % num_workers == 0): 37 | print '%i,%i,%f'% (clocks[i], times[i] - times[num_workers - 1], count / num_workers) 38 | count = 0 39 | -------------------------------------------------------------------------------- /apps/caffe/scripts/travis/travis_setup_makefile_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | mv Makefile.config.example Makefile.config 6 | 7 | if $WITH_CUDA; then 8 | # Only generate compute_50. 9 | GENCODE="-gencode arch=compute_50,code=sm_50" 10 | GENCODE="$GENCODE -gencode arch=compute_50,code=compute_50" 11 | echo "CUDA_ARCH := $GENCODE" >> Makefile.config 12 | fi 13 | 14 | # Remove IO library settings from Makefile.config 15 | # to avoid conflicts with CI configuration 16 | sed -i -e '/USE_LMDB/d' Makefile.config 17 | sed -i -e '/USE_LEVELDB/d' Makefile.config 18 | sed -i -e '/USE_OPENCV/d' Makefile.config 19 | 20 | cat << 'EOF' >> Makefile.config 21 | # Travis' nvcc doesn't like newer boost versions 22 | NVCCFLAGS := -Xcudafe --diag_suppress=cc_clobber_ignored -Xcudafe --diag_suppress=useless_using_declaration -Xcudafe --diag_suppress=set_but_not_used 23 | ANACONDA_HOME := $(CONDA_DIR) 24 | PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ 25 | $(ANACONDA_HOME)/include/python2.7 \ 26 | $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include 27 | PYTHON_LIB := $(ANACONDA_HOME)/lib 28 | INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include 29 | LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 30 | WITH_PYTHON_LAYER := 1 31 | EOF 32 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/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 | <<>>( 23 | N, g, h, h2, momentum, delta, local_rate); 24 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 25 | } 26 | template void adadelta_update_gpu(int , float*, float*, float*, 27 | float, float, float); 28 | template void adadelta_update_gpu(int, double*, double*, double*, 29 | double, double, double); 30 | 31 | } // namespace caffe 32 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/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 | <<>>( 22 | N, g, m, v, beta1, beta2, eps_hat, corrected_local_rate); 23 | CUDA_CHECK(cudaStreamSynchronize(Caffe::cuda_stream())); 24 | } 25 | template void adam_update_gpu(int, float*, float*, float*, 26 | float, float, float, float); 27 | template void adam_update_gpu(int, double*, double*, double*, 28 | double, double, double, double); 29 | 30 | } // namespace caffe 31 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/hdf5.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_UTIL_HDF5_H_ 2 | #define CAFFE_UTIL_HDF5_H_ 3 | 4 | #include 5 | 6 | #include "hdf5.h" 7 | #include "hdf5_hl.h" 8 | 9 | #include "caffe/blob.hpp" 10 | 11 | namespace caffe { 12 | 13 | template 14 | void hdf5_load_nd_dataset_helper( 15 | hid_t file_id, const char* dataset_name_, int min_dim, int max_dim, 16 | Blob* blob); 17 | 18 | template 19 | void hdf5_load_nd_dataset( 20 | hid_t file_id, const char* dataset_name_, int min_dim, int max_dim, 21 | Blob* blob); 22 | 23 | template 24 | void hdf5_save_nd_dataset( 25 | const hid_t file_id, const string& dataset_name, const Blob& blob, 26 | bool write_diff = false); 27 | 28 | int hdf5_load_int(hid_t loc_id, const string& dataset_name); 29 | void hdf5_save_int(hid_t loc_id, const string& dataset_name, int i); 30 | string hdf5_load_string(hid_t loc_id, const string& dataset_name); 31 | void hdf5_save_string(hid_t loc_id, const string& dataset_name, 32 | const string& s); 33 | 34 | int hdf5_get_num_links(hid_t loc_id); 35 | string hdf5_get_name_by_idx(hid_t loc_id, int idx); 36 | 37 | } // namespace caffe 38 | 39 | #endif // CAFFE_UTIL_HDF5_H_ 40 | -------------------------------------------------------------------------------- /apps/caffe/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/sequence_layers.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 | for (int i = 0; i < recur_input_blobs_.size(); ++i) { 23 | const int count = recur_input_blobs_[i]->count(); 24 | DCHECK_EQ(count, recur_output_blobs_[i]->count()); 25 | const Dtype* timestep_T_data = recur_output_blobs_[i]->gpu_data(); 26 | Dtype* timestep_0_data = recur_input_blobs_[i]->mutable_gpu_data(); 27 | caffe_copy(count, timestep_T_data, timestep_0_data); 28 | } 29 | 30 | unrolled_net_->ForwardPrefilled(); 31 | } 32 | 33 | INSTANTIATE_LAYER_GPU_FORWARD(RecurrentLayer); 34 | 35 | } // namespace caffe 36 | -------------------------------------------------------------------------------- /scripts/install-caffe-deps-ubuntu16.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update 2 | sudo apt-get install -y --force-yes libatlas-base-dev 3 | sudo apt-get install -y --force-yes libopencv-dev 4 | sudo apt-get install -y --force-yes protobuf-compiler 5 | sudo apt-get install -y --force-yes libprotobuf-dev 6 | sudo apt-get install -y --force-yes libgoogle-glog-dev 7 | sudo apt-get install -y --force-yes libgflags-dev 8 | sudo apt-get install -y --force-yes libhdf5-dev 9 | sudo apt-get install -y --force-yes libleveldb-dev 10 | sudo apt-get install -y --force-yes libsnappy-dev 11 | sudo apt-get install -y --force-yes liblmdb-dev 12 | sudo apt-get install -y --force-yes libpython-dev 13 | sudo apt-get install -y --force-yes libboost-python-dev 14 | sudo apt-get install -y --force-yes libboost-filesystem-dev 15 | sudo apt-get install -y --force-yes cython 16 | sudo apt-get install -y --force-yes python-numpy 17 | sudo apt-get install -y --force-yes python-protobuf 18 | sudo apt-get install -y --force-yes python-skimage 19 | sudo apt-get install -y --force-yes python-h5py 20 | sudo apt-get install -y --force-yes python-matplotlib 21 | sudo apt-get install -y --force-yes openjdk-7-jre 22 | sudo cp /usr/include/hdf5/serial/* /usr/include/. 23 | sudo cp /usr/lib/x86_64-linux-gnu/hdf5/serial/* /usr/local/lib/. 24 | -------------------------------------------------------------------------------- /apps/caffe/scripts/gather_examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Assemble documentation for the project into one directory via symbolic links. 3 | 4 | # Find the docs dir, no matter where the script is called 5 | ROOT_DIR="$( cd "$(dirname "$0")"/.. ; pwd -P )" 6 | cd $ROOT_DIR 7 | 8 | # Gather docs from examples/**/readme.md 9 | GATHERED_DIR=docs/gathered 10 | rm -r $GATHERED_DIR 11 | mkdir $GATHERED_DIR 12 | for README_FILENAME in $(find examples -iname "readme.md"); do 13 | # Only use file if it is to be included in docs. 14 | if grep -Fxq "include_in_docs: true" $README_FILENAME; then 15 | # Make link to readme.md in docs/gathered/. 16 | # Since everything is called readme.md, rename it by its dirname. 17 | README_DIRNAME=`dirname $README_FILENAME` 18 | DOCS_FILENAME=$GATHERED_DIR/$README_DIRNAME.md 19 | mkdir -p `dirname $DOCS_FILENAME` 20 | ln -s $ROOT_DIR/$README_FILENAME $DOCS_FILENAME 21 | fi 22 | done 23 | 24 | # Gather docs from examples/*.ipynb and add YAML front-matter. 25 | for NOTEBOOK_FILENAME in $(find examples -depth -iname "*.ipynb"); do 26 | DOCS_FILENAME=$GATHERED_DIR/$NOTEBOOK_FILENAME 27 | mkdir -p `dirname $DOCS_FILENAME` 28 | python scripts/copy_notebook.py $NOTEBOOK_FILENAME $DOCS_FILENAME 29 | done 30 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/1parts/train_gnlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -p 3022 -w ^examples/cifar10/1parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 12 | sed -i ''"${SED_STR}"'' ./examples/cifar10/1parts/gnlenet_solver.prototxt.template 13 | cp examples/cifar10/1parts/train_gnlenet.sh $1/. 14 | cp examples/cifar10/1parts/gnlenet_train_val.prototxt.template $1/. 15 | cp examples/cifar10/1parts/gnlenet_solver.prototxt.template $1/. 16 | cp examples/cifar10/1parts/machinefile $1/. 17 | cp examples/cifar10/1parts/ps_config_gnlenet $1/. 18 | LOG=$1/output.txt 19 | OUTDIR=$1 20 | fi 21 | 22 | python scripts/duplicate.py examples/cifar10/1parts/gnlenet_train_val.prototxt 1 23 | python scripts/duplicate.py examples/cifar10/1parts/gnlenet_solver.prototxt 1 24 | 25 | pdsh -R ssh -p 3022 -w ^examples/cifar10/1parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/1parts/gnlenet_solver.prototxt --ps_config=examples/cifar10/1parts/ps_config_gnlenet --machinefile=examples/cifar10/1parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 26 | -------------------------------------------------------------------------------- /apps/caffe/examples/casia/4parts/train_face.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/4parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.]*"#snapshot_prefix: "'"${1}"'/face_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/casia/4parts/face_solver.prototxt.template 15 | cp examples/casia/4parts/train_face.sh $1/. 16 | cp examples/casia/4parts/face_train_test.prototxt.template $1/. 17 | cp examples/casia/4parts/face_solver.prototxt.template $1/. 18 | cp examples/casia/4parts/machinefile $1/. 19 | cp examples/casia/4parts/ps_config_face $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | rm ${LOG} 25 | 26 | python scripts/duplicate.py examples/casia/4parts/face_train_test.prototxt 4 27 | python scripts/duplicate.py examples/casia/4parts/face_solver.prototxt 4 28 | 29 | pdsh -R ssh -w ^examples/casia/4parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/casia/4parts/face_solver.prototxt --ps_config=examples/casia/4parts/ps_config_face --machinefile=examples/casia/4parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 30 | 31 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_lenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/lenet_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_lenet.sh $1/. 16 | cp examples/cifar10/5parts/lenet_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/lenet_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_lenet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/lenet_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/lenet_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/lenet_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_lenet --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/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 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/db.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_UTIL_DB_HPP 2 | #define CAFFE_UTIL_DB_HPP 3 | 4 | #include 5 | 6 | #include "caffe/common.hpp" 7 | #include "caffe/proto/caffe.pb.h" 8 | 9 | namespace caffe { namespace db { 10 | 11 | enum Mode { READ, WRITE, NEW }; 12 | 13 | class Cursor { 14 | public: 15 | Cursor() { } 16 | virtual ~Cursor() { } 17 | virtual void SeekToFirst() = 0; 18 | virtual void Next() = 0; 19 | virtual string key() = 0; 20 | virtual string value() = 0; 21 | virtual bool valid() = 0; 22 | 23 | DISABLE_COPY_AND_ASSIGN(Cursor); 24 | }; 25 | 26 | class Transaction { 27 | public: 28 | Transaction() { } 29 | virtual ~Transaction() { } 30 | virtual void Put(const string& key, const string& value) = 0; 31 | virtual void Commit() = 0; 32 | 33 | DISABLE_COPY_AND_ASSIGN(Transaction); 34 | }; 35 | 36 | class DB { 37 | public: 38 | DB() { } 39 | virtual ~DB() { } 40 | virtual void Open(const string& source, Mode mode) = 0; 41 | virtual void Close() = 0; 42 | virtual Cursor* NewCursor() = 0; 43 | virtual Transaction* NewTransaction() = 0; 44 | 45 | DISABLE_COPY_AND_ASSIGN(DB); 46 | }; 47 | 48 | DB* GetDB(DataParameter::DB backend); 49 | DB* GetDB(const string& backend); 50 | 51 | } // namespace db 52 | } // namespace caffe 53 | 54 | #endif // CAFFE_UTIL_DB_HPP 55 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_alexnet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/alexnet_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_alexnet.sh $1/. 16 | cp examples/cifar10/5parts/alexnet_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/alexnet_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_alexnet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/alexnet_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/alexnet_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/alexnet_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_alexnet --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_bnlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/bnlenet_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_bnlenet.sh $1/. 16 | cp examples/cifar10/5parts/bnlenet_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/bnlenet_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_bnlenet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/bnlenet_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/bnlenet_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/bnlenet_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_bnlenet --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_gnlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/gnlenet_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_gnlenet.sh $1/. 16 | cp examples/cifar10/5parts/gnlenet_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/gnlenet_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_gnlenet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/gnlenet_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/gnlenet_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/gnlenet_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_gnlenet --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/scripts/summarize-accuracy2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from datetime import datetime, timedelta 4 | 5 | input_file = sys.argv[1] 6 | num_workers = 8 7 | if len(sys.argv) > 2: 8 | num_workers = int(sys.argv[2]) 9 | 10 | input_fd = open(input_file, 'r') 11 | times = [] 12 | accuracys = [] 13 | time_start = 0 14 | for line in input_fd: 15 | strs = line.split() 16 | if time_start == 0 and (len(strs) == 9 or len(strs) == 10) and strs[6] == 'loss': 17 | time_tuple = datetime.strptime(strs[1], "%H:%M:%S.%f") 18 | time_start = time_tuple.hour * 3600 + time_tuple.minute * 60 + time_tuple.second 19 | if not len(strs) == 11: 20 | continue 21 | if not strs[8] == 'accuracy2' and not strs[8] == 'loss3/top-5': 22 | continue 23 | # times.append(float(strs[5][:-1])) 24 | time_tuple = datetime.strptime(strs[1], "%H:%M:%S.%f") 25 | times.append(time_tuple.hour * 3600 + time_tuple.minute * 60 + time_tuple.second) 26 | accuracys.append(float(strs[10])) 27 | 28 | n = len(accuracys) 29 | count = 0 30 | for i in range(n): 31 | if times[i] < times[0]: 32 | times[i] = times[i] + 86400 33 | # print '%i,%i,%f'% (clocks[i], times[i] - times[0], losses[i]) 34 | count = count + accuracys[i] 35 | if ((i + 1) % num_workers == 0): 36 | print '%i,%f'% (times[i] - time_start, count / num_workers) 37 | count = 0 38 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_brnlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/brnlenet_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_brnlenet.sh $1/. 16 | cp examples/cifar10/5parts/brnlenet_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/brnlenet_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_brnlenet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/brnlenet_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/brnlenet_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/brnlenet_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_brnlenet --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_resnet20.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/resnet20_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_resnet20.sh $1/. 16 | cp examples/cifar10/5parts/resnet20_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/resnet20_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_resnet20 $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/resnet20_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/resnet20_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/resnet20_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_resnet20 --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/layers/data_layer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_DATA_LAYER_HPP_ 2 | #define CAFFE_DATA_LAYER_HPP_ 3 | 4 | #include 5 | 6 | #include "caffe/blob.hpp" 7 | #include "caffe/data_reader.hpp" 8 | #include "caffe/data_transformer.hpp" 9 | #include "caffe/internal_thread.hpp" 10 | #include "caffe/layer.hpp" 11 | #include "caffe/layers/base_data_layer.hpp" 12 | #include "caffe/proto/caffe.pb.h" 13 | #include "caffe/util/db.hpp" 14 | 15 | namespace caffe { 16 | 17 | template 18 | class DataLayer : public BasePrefetchingDataLayer { 19 | public: 20 | explicit DataLayer(const LayerParameter& param); 21 | virtual ~DataLayer(); 22 | virtual void DataLayerSetUp(const vector*>& bottom, 23 | const vector*>& top); 24 | // DataLayer uses DataReader instead for sharing for parallelism 25 | virtual inline bool ShareInParallel() const { return false; } 26 | virtual inline const char* type() const { return "Data"; } 27 | virtual inline int ExactNumBottomBlobs() const { return 0; } 28 | virtual inline int MinTopBlobs() const { return 1; } 29 | virtual inline int MaxTopBlobs() const { return 2; } 30 | 31 | protected: 32 | virtual void load_batch(Batch* batch); 33 | 34 | DataReader reader_; 35 | }; 36 | 37 | } // namespace caffe 38 | 39 | #endif // CAFFE_DATA_LAYER_HPP_ 40 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_googlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/googlenet_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_googlenet.sh $1/. 16 | cp examples/cifar10/5parts/googlenet_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/googlenet_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_googlenet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/googlenet_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/googlenet_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/googlenet_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_googlenet --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_resnet20e.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/resnet20e_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_resnet20e.sh $1/. 16 | cp examples/cifar10/5parts/resnet20e_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/resnet20e_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_resnet20e $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/resnet20e_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/resnet20e_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/resnet20e_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_resnet20e --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_googlenete.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/googlenete_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_googlenete.sh $1/. 16 | cp examples/cifar10/5parts/googlenete_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/googlenete_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_googlenete $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/googlenete_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/googlenete_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/googlenete_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_googlenete --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/cifar10/5parts/train_resnetgn20.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.,]*"#snapshot_prefix: "'"${1}"'/cifar_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/cifar10/5parts/resnetgn20_solver.prototxt.template 15 | cp examples/cifar10/5parts/train_resnetgn20.sh $1/. 16 | cp examples/cifar10/5parts/resnetgn20_train_val.prototxt.template $1/. 17 | cp examples/cifar10/5parts/resnetgn20_solver.prototxt.template $1/. 18 | cp examples/cifar10/5parts/machinefile $1/. 19 | cp examples/cifar10/5parts/ps_config_resnetgn20 $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/cifar10/5parts/resnetgn20_train_val.prototxt 5 25 | python scripts/duplicate.py examples/cifar10/5parts/resnetgn20_solver.prototxt 5 26 | 27 | pdsh -R ssh -w ^examples/cifar10/5parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/cifar10/5parts/resnetgn20_solver.prototxt --ps_config=examples/cifar10/5parts/ps_config_resnetgn20 --machinefile=examples/cifar10/5parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/train_resnet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.]*"#snapshot_prefix: "'"${1}"'/resnet_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/imagenet/8parts/resnet_50_solver.prototxt.template 15 | cp examples/imagenet/8parts/train_resnet.sh $1/. 16 | cp examples/imagenet/8parts/resnet_50.prototxt.template $1/. 17 | cp examples/imagenet/8parts/resnet_50_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_resnet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | rm ${LOG} 25 | 26 | python scripts/duplicate.py examples/imagenet/8parts/resnet_50.prototxt 8 27 | python scripts/duplicate.py examples/imagenet/8parts/resnet_50_solver.prototxt 8 28 | 29 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/resnet_50_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_resnet --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 30 | 31 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/train_resnet10.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.]*"#snapshot_prefix: "'"${1}"'/resnet_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/imagenet/8parts/resnet10_solver.prototxt.template 15 | cp examples/imagenet/8parts/train_resnet.sh $1/. 16 | cp examples/imagenet/8parts/resnet10.prototxt.template $1/. 17 | cp examples/imagenet/8parts/resnet10_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_resnet10 $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | rm ${LOG} 25 | 26 | python scripts/duplicate.py examples/imagenet/8parts/resnet10.prototxt 8 27 | python scripts/duplicate.py examples/imagenet/8parts/resnet10_solver.prototxt 8 28 | 29 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/resnet10_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_resnet10 --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 30 | 31 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/rng.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_RNG_CPP_HPP_ 2 | #define CAFFE_RNG_CPP_HPP_ 3 | 4 | #include 5 | #include 6 | 7 | #include "boost/random/mersenne_twister.hpp" 8 | #include "boost/random/uniform_int.hpp" 9 | 10 | #include "caffe/common.hpp" 11 | 12 | namespace caffe { 13 | 14 | typedef boost::mt19937 rng_t; 15 | 16 | inline rng_t* caffe_rng() { 17 | return static_cast(Caffe::rng_stream().generator()); 18 | } 19 | 20 | // Fisher–Yates algorithm 21 | template 22 | inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end, 23 | RandomGenerator* gen) { 24 | typedef typename std::iterator_traits::difference_type 25 | difference_type; 26 | typedef typename boost::uniform_int dist_type; 27 | 28 | difference_type length = std::distance(begin, end); 29 | if (length <= 0) return; 30 | 31 | for (difference_type i = length - 1; i > 0; --i) { 32 | dist_type dist(0, i); 33 | std::iter_swap(begin + i, begin + dist(*gen)); 34 | } 35 | } 36 | 37 | template 38 | inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end) { 39 | shuffle(begin, end, caffe_rng()); 40 | } 41 | } // namespace caffe 42 | 43 | #endif // CAFFE_RNG_HPP_ 44 | -------------------------------------------------------------------------------- /apps/caffe/include/caffe/util/benchmark.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAFFE_UTIL_BENCHMARK_H_ 2 | #define CAFFE_UTIL_BENCHMARK_H_ 3 | 4 | #include 5 | 6 | #include "caffe/util/device_alternate.hpp" 7 | 8 | namespace caffe { 9 | 10 | class Timer { 11 | public: 12 | Timer(); 13 | virtual ~Timer(); 14 | virtual void Start(); 15 | virtual void Stop(); 16 | virtual float MilliSeconds(); 17 | virtual float MicroSeconds(); 18 | virtual float Seconds(); 19 | 20 | inline bool initted() { return initted_; } 21 | inline bool running() { return running_; } 22 | inline bool has_run_at_least_once() { return has_run_at_least_once_; } 23 | 24 | protected: 25 | void Init(); 26 | 27 | bool initted_; 28 | bool running_; 29 | bool has_run_at_least_once_; 30 | #ifndef CPU_ONLY 31 | cudaEvent_t start_gpu_; 32 | cudaEvent_t stop_gpu_; 33 | #endif 34 | boost::posix_time::ptime start_cpu_; 35 | boost::posix_time::ptime stop_cpu_; 36 | float elapsed_milliseconds_; 37 | float elapsed_microseconds_; 38 | }; 39 | 40 | class CPUTimer : public Timer { 41 | public: 42 | explicit CPUTimer(); 43 | virtual ~CPUTimer() {} 44 | virtual void Start(); 45 | virtual void Stop(); 46 | virtual float MilliSeconds(); 47 | virtual float MicroSeconds(); 48 | }; 49 | 50 | } // namespace caffe 51 | 52 | #endif // CAFFE_UTIL_BENCHMARK_H_ 53 | -------------------------------------------------------------------------------- /apps/caffe/scripts/upload_model_to_gist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for valid directory 4 | DIRNAME=$1 5 | if [ ! -f $DIRNAME/readme.md ]; then 6 | echo "usage: upload_model_to_gist.sh " 7 | echo " /readme.md must exist" 8 | fi 9 | cd $DIRNAME 10 | FILES=`find . -maxdepth 1 -type f ! -name "*.caffemodel*" | xargs echo` 11 | 12 | # Check for gist tool. 13 | gist -v >/dev/null 2>&1 || { echo >&2 "I require 'gist' but it's not installed. Do 'gem install gist'."; exit 1; } 14 | 15 | NAME=`sed -n 's/^name:[[:space:]]*//p' readme.md` 16 | if [ -z "$NAME" ]; then 17 | echo " /readme.md must contain name field in the front-matter." 18 | fi 19 | 20 | GIST=`sed -n 's/^gist_id:[[:space:]]*//p' readme.md` 21 | if [ -z "$GIST" ]; then 22 | echo "Uploading new Gist" 23 | gist -p -d "$NAME" $FILES 24 | else 25 | echo "Updating existing Gist, id $GIST" 26 | gist -u $GIST -d "$NAME" $FILES 27 | fi 28 | 29 | RESULT=$? 30 | if [ $RESULT -eq 0 ]; then 31 | echo "You've uploaded your model!" 32 | echo "Don't forget to add the gist_id field to your /readme.md now!" 33 | echo "Run the command again after you do that, to make sure the Gist id propagates." 34 | echo "" 35 | echo "And do share your model over at https://github.com/BVLC/caffe/wiki/Model-Zoo" 36 | else 37 | echo "Something went wrong!" 38 | fi 39 | -------------------------------------------------------------------------------- /apps/caffe/examples/imagenet/8parts/train_googlenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "pkill caffe_geeps" 4 | 5 | LOG=output.txt 6 | OUTDIR= 7 | 8 | if [ "$#" -eq 1 ]; then 9 | mkdir $1 10 | pwd > $1/pwd 11 | git status > $1/git-status 12 | git diff > $1/git-diff 13 | SED_STR='s#snapshot_prefix: "[a-zA-Z0-9/_.]*"#snapshot_prefix: "'"${1}"'/googlenet_snapshot"#g' 14 | sed -i ''"${SED_STR}"'' ./examples/imagenet/8parts/googlenet_solver.prototxt.template 15 | cp examples/imagenet/8parts/train_googlenet.sh $1/. 16 | cp examples/imagenet/8parts/googlenet_train_val.prototxt.template $1/. 17 | cp examples/imagenet/8parts/googlenet_solver.prototxt.template $1/. 18 | cp examples/imagenet/8parts/machinefile $1/. 19 | cp examples/imagenet/8parts/ps_config_googlenet $1/. 20 | LOG=$1/output.txt 21 | OUTDIR=$1 22 | fi 23 | 24 | python scripts/duplicate.py examples/imagenet/8parts/googlenet_train_val.prototxt 8 25 | python scripts/duplicate.py examples/imagenet/8parts/googlenet_solver.prototxt 8 26 | 27 | pdsh -R ssh -w ^examples/imagenet/8parts/machinefile "cd $(pwd) && ./build/tools/caffe_geeps train --solver=examples/imagenet/8parts/googlenet_solver.prototxt --ps_config=examples/imagenet/8parts/ps_config_googlenet --machinefile=examples/imagenet/8parts/machinefile --worker_id=%n --outdir=${OUTDIR}" 2>&1 | tee ${LOG} 28 | 29 | -------------------------------------------------------------------------------- /apps/caffe/matlab/+caffe/get_net.m: -------------------------------------------------------------------------------- 1 | function net = get_net(varargin) 2 | % net = get_net(model_file, phase_name) or 3 | % net = get_net(model_file, weights_file, phase_name) 4 | % Construct a net from model_file, and load weights from weights_file 5 | % phase_name can only be 'train' or 'test' 6 | 7 | CHECK(nargin == 2 || nargin == 3, ['usage: ' ... 8 | 'net = get_net(model_file, phase_name) or ' ... 9 | 'net = get_net(model_file, weights_file, phase_name)']); 10 | if nargin == 3 11 | model_file = varargin{1}; 12 | weights_file = varargin{2}; 13 | phase_name = varargin{3}; 14 | elseif nargin == 2 15 | model_file = varargin{1}; 16 | phase_name = varargin{2}; 17 | end 18 | 19 | CHECK(ischar(model_file), 'model_file must be a string'); 20 | CHECK(ischar(phase_name), 'phase_name must be a string'); 21 | CHECK_FILE_EXIST(model_file); 22 | CHECK(strcmp(phase_name, 'train') || strcmp(phase_name, 'test'), ... 23 | sprintf('phase_name can only be %strain%s or %stest%s', ... 24 | char(39), char(39), char(39), char(39))); 25 | 26 | % construct caffe net from model_file 27 | hNet = caffe_('get_net', model_file, phase_name); 28 | net = caffe.Net(hNet); 29 | 30 | % load weights from weights_file 31 | if nargin == 3 32 | CHECK(ischar(weights_file), 'weights_file must be a string'); 33 | CHECK_FILE_EXIST(weights_file); 34 | net.copy_from(weights_file); 35 | end 36 | 37 | end 38 | --------------------------------------------------------------------------------