diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/README.md | 6 | ||||
-rw-r--r-- | docs/_layouts/default.html | 29 | ||||
-rw-r--r-- | docs/cifar10.md | 95 | ||||
-rw-r--r-- | docs/development.md | 11 | ||||
-rw-r--r-- | docs/feature_extraction.md | 71 | ||||
-rw-r--r-- | docs/getting_pretrained_models.md | 5 | ||||
-rw-r--r-- | docs/imagenet_training.md | 102 | ||||
-rw-r--r-- | docs/index.md | 59 | ||||
-rw-r--r-- | docs/javascripts/scale.fix.js | 20 | ||||
-rw-r--r-- | docs/mnist.md | 91 | ||||
-rw-r--r-- | docs/mnist_prototxt.md | 153 | ||||
-rw-r--r-- | docs/mnist_solver_prototxt.md | 37 | ||||
-rw-r--r-- | docs/stylesheets/styles.css | 65 |
13 files changed, 68 insertions, 676 deletions
diff --git a/docs/README.md b/docs/README.md index 81e1566b..8f1781e3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,5 @@ -To generate stuff you can paste in an .md page from an IPython notebook, run +# Caffe Documentation - ipython nbconvert --to markdown <notebook_file> +To generate the documentation, run `$CAFFE_ROOT/scripts/build_docs.sh`. + +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 <repo_name>`. diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index f5d90004..756e8eba 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -7,10 +7,10 @@ Caffe {% if page contains 'title' %}| {{ page.title }}{% endif %} </title> - <link rel="stylesheet" href="stylesheets/reset.css"> - <link rel="stylesheet" href="stylesheets/styles.css"> - <link rel="stylesheet" href="stylesheets/pygment_trac.css"> - <script src="javascripts/scale.fix.js"></script> + <link rel="stylesheet" href="/stylesheets/reset.css"> + <link rel="stylesheet" href="/stylesheets/styles.css"> + <link rel="stylesheet" href="/stylesheets/pygment_trac.css"> + <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> @@ -28,28 +28,21 @@ </script> <div class="wrapper"> <header> - <h1 class="header"><a href="index.html">Caffe</a></h1> - <!-- <p class="header">Convolutional Architecture for Fast Feature Embedding</p> --> - + <h1 class="header"><a href="/">Caffe</a></h1> + <p class="header"> + Deep learning framework developed by <a class="header name" href="http://daggerfs.com/">Yangqing Jia</a> / <a class="header name" href="http://bvlc.eecs.berkeley.edu/">BVLC</a> + </p> <ul> - <!--<li class="download"><a class="buttons" href="https://github.com/BVLC/caffe/zipball/master">Download ZIP</a></li> - <li class="download"><a class="buttons" href="https://github.com/BVLC/caffe/tarball/master">Download TAR</a></li>--> - <li><a class="buttons github" href="https://github.com/BVLC/caffe">View On GitHub</a></li> + <li> + <a class="buttons github" href="https://github.com/BVLC/caffe">View On GitHub</a> + </li> </ul> - <p class="header">Maintained by<br><a class="header name" href="http://bvlc.eecs.berkeley.edu/">BVLC</a></p> - <p class="header">Created by<br><a class="header name" href="http://daggerfs.com/">Yangqing Jia</a></p> - </header> <section> {{ content }} </section> -<!-- <footer> - <p><small>Hosted on <a href="http://pages.github.com">GitHub Pages</a>.</small></p> - </footer> - --> </div> - <!--[if !IE]><script>fixScale(document);</script><![endif]--> </body> </html> diff --git a/docs/cifar10.md b/docs/cifar10.md deleted file mode 100644 index dd85667d..00000000 --- a/docs/cifar10.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -layout: default -title: Caffe ---- - -Alex's CIFAR-10 tutorial, Caffe style -===================================== - -Alex Krizhevsky's [cuda-convnet](https://code.google.com/p/cuda-convnet/) details the model definitions, parameters, and training procedure for good performance on CIFAR-10. This example reproduces his results in Caffe. - -We will assume that you have Caffe successfully compiled. If not, please refer to the [Installation page](installation.html). In this tutorial, we will assume that your caffe installation is located at `CAFFE_ROOT`. - -We thank @chyojn for the pull request that defined the model schemas and solver configurations. - -*This example is a work-in-progress. It would be nice to further explain details of the network and training choices and benchmark the full training.* - -Prepare the Dataset -------------------- - -You will first need to download and convert the data format from the [CIFAR-10 website](http://www.cs.toronto.edu/~kriz/cifar.html). To do this, simply run the following commands: - - cd $CAFFE_ROOT/data/cifar10 - ./get_cifar10.sh - cd $CAFFE_ROOT/examples/cifar10 - ./create_cifar10.sh - -If it complains that `wget` or `gunzip` are not installed, you need to install them respectively. After running the script there should be the dataset, `./cifar10-leveldb`, and the data set image mean `./mean.binaryproto`. - -The Model ---------- - -The CIFAR-10 model is a CNN that composes layers of convolution, pooling, rectified linear unit (ReLU) nonlinearities, and local contrast normalization with a linear classifier on top of it all. We have defined the model in the `CAFFE_ROOT/examples/cifar10` directory's `cifar10_quick_train.prototxt`. - -Training and Testing the "Quick" Model --------------------------------------- - -Training the model is simple after you have written the network definition protobuf and solver protobuf files. Simply run `train_quick.sh`, or the following command directly: - - cd $CAFFE_ROOT/examples/cifar10 - ./train_quick.sh - -`train_quick.sh` is a simple script, so have a look inside. `GLOG_logtostderr=1` is the google logging flag that prints all the logging messages directly to stderr. The main tool for training is `train_net.bin`, with the solver protobuf text file as its argument. - -When you run the code, you will see a lot of messages flying by like this: - - I0317 21:52:48.945710 2008298256 net.cpp:74] Creating Layer conv1 - I0317 21:52:48.945716 2008298256 net.cpp:84] conv1 <- data - I0317 21:52:48.945725 2008298256 net.cpp:110] conv1 -> conv1 - I0317 21:52:49.298691 2008298256 net.cpp:125] Top shape: 100 32 32 32 (3276800) - I0317 21:52:49.298719 2008298256 net.cpp:151] conv1 needs backward computation. - -These messages tell you the details about each layer, its connections and its output shape, which may be helpful in debugging. After the initialization, the training will start: - - I0317 21:52:49.309370 2008298256 net.cpp:166] Network initialization done. - I0317 21:52:49.309376 2008298256 net.cpp:167] Memory required for Data 23790808 - I0317 21:52:49.309422 2008298256 solver.cpp:36] Solver scaffolding done. - I0317 21:52:49.309447 2008298256 solver.cpp:47] Solving CIFAR10_quick_train - -Based on the solver setting, we will print the training loss function every 100 iterations, and test the network every 500 iterations. You will see messages like this: - - I0317 21:53:12.179772 2008298256 solver.cpp:208] Iteration 100, lr = 0.001 - I0317 21:53:12.185698 2008298256 solver.cpp:65] Iteration 100, loss = 1.73643 - ... - I0317 21:54:41.150030 2008298256 solver.cpp:87] Iteration 500, Testing net - I0317 21:54:47.129461 2008298256 solver.cpp:114] Test score #0: 0.5504 - I0317 21:54:47.129500 2008298256 solver.cpp:114] Test score #1: 1.27805 - -For each training iteration, `lr` is the learning rate of that iteration, and `loss` is the training function. For the output of the testing phase, **score 0 is the accuracy**, and **score 1 is the testing loss function**. - -And after making yourself a cup of coffee, you are done! - - I0317 22:12:19.666914 2008298256 solver.cpp:87] Iteration 5000, Testing net - I0317 22:12:25.580330 2008298256 solver.cpp:114] Test score #0: 0.7533 - I0317 22:12:25.580379 2008298256 solver.cpp:114] Test score #1: 0.739837 - I0317 22:12:25.587262 2008298256 solver.cpp:130] Snapshotting to cifar10_quick_iter_5000 - I0317 22:12:25.590215 2008298256 solver.cpp:137] Snapshotting solver state to cifar10_quick_iter_5000.solverstate - I0317 22:12:25.592813 2008298256 solver.cpp:81] Optimization Done. - -Our model achieved ~75% test accuracy. The model parameters are stored in binary protobuf format in - - cifar10_quick_iter_5000 - -which is ready-to-deploy in CPU or GPU mode! Refer to the `CAFFE_ROOT/examples/cifar10/cifar10_quick.prototxt` for the deployment model definition that can be called on new data. - -Why train on a GPU? -------------------- - -CIFAR-10, while still small, has enough data to make GPU training attractive. - -To compare CPU vs. GPU training speed, simply change one line in all the `cifar*solver.prototxt`: - - # solver mode: CPU or GPU - solver_mode: CPU - -and you will be using CPU for training. diff --git a/docs/development.md b/docs/development.md index 444c9e8e..ff734d17 100644 --- a/docs/development.md +++ b/docs/development.md @@ -9,9 +9,14 @@ The [BVLC](http://bvlc.eecs.berkeley.edu/) maintainers welcome all contributions ### Documentation -Tutorials and general documentation -- including this website -- are written in Markdown format in the `docs/` folder. -While the format is quite easy to read directly, you may prefer to view the whole thing as a website. -To do so, simply run `jekyll serve -s docs` and view the documentation website at `http://0.0.0.0:4000` (for [jekyll](http://jekyllrb.com/), you must have ruby and do `gem install jekyll`). +This website, written with [Jekyll](http://jekyllrb.com/), functions as the official Caffe documentation -- simply run `scripts/build_docs.sh` and view the website at `http://0.0.0.0:4000`. + +We prefer tutorials and examples to be documented close to where they live, in `readme.md` files. +The `build_docs.sh` script gathers all `examples/**/readme.md` and `examples/*.ipynb` files, and makes a table of contents. +To be included in the docs, the readme files must be annotated with [YAML front-matter](http://jekyllrb.com/docs/frontmatter/), including the flag `include_in_docs: true`. +Similarly for IPython notebooks: simply include `"include_in_docs": true` in the `"metadata"` JSON field. + +Other docs, such as installation guides, are written in the `docs` directory and manually linked to from the `index.md` page. We strive to provide provide lots of usage examples, and to document all code in docstrings. We absolutely appreciate any contribution to this effort! diff --git a/docs/feature_extraction.md b/docs/feature_extraction.md deleted file mode 100644 index fa23e9c8..00000000 --- a/docs/feature_extraction.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -layout: default -title: Caffe ---- - -Extracting Features -=================== - -In this tutorial, we will extract features using a pre-trained model. -Follow instructions for [setting up caffe](installation.html) and for [getting](getting_pretrained_models.html) the pre-trained ImageNet model. -If you need detailed information about the tools below, please consult their source code, in which additional documentation is usually provided. - -Select data to run on ---------------------- - -We'll make a temporary folder to store things into. - - mkdir examples/_temp - -Generate a list of the files to process. -We're going to use the images that ship with caffe. - - find `pwd`/examples/images -type f -exec echo {} \; > examples/_temp/temp.txt - -The `ImageDataLayer` we'll use expects labels after each filenames, so let's add a 0 to the end of each line - - sed "s/$/ 0/" examples/_temp/temp.txt > examples/_temp/file_list.txt - -Define the Feature Extraction Network Architecture --------------------------------------------------- - -In practice, subtracting the mean image from a dataset significantly improves classification accuracies. -Download the mean image of the ILSVRC dataset. - - data/ilsvrc12/get_ilsvrc_aux.sh - -We will use `data/ilsvrc212/imagenet_mean.binaryproto` in the network definition prototxt. - -Let's copy and modify the network definition. -We'll be using the `ImageDataLayer`, which will load and resize images for us. - - cp examples/feature_extraction/imagenet_val.prototxt examples/_temp - -Edit `examples/_temp/imagenet_val.prototxt` to use correct path for your setup (replace `$CAFFE_DIR`) - -Extract Features ----------------- - -Now everything necessary is in place. - - build/tools/extract_features.bin examples/imagenet/caffe_reference_imagenet_model examples/_temp/imagenet_val.prototxt fc7 examples/_temp/features 10 - -The name of feature blob that you extract is `fc7`, which represents the highest level feature of the reference model. -We can use any other layer, as well, such as `conv5` or `pool3`. - -The last parameter above is the number of data mini-batches. - -The features are stored to LevelDB `examples/_temp/features`, ready for access by some other code. - -If you meet with the error "Check failed: status.ok() Failed to open leveldb examples/_temp/features", it is because the directory examples/_temp/features has been created the last time you run the command. Remove it and run again. - - rm -rf examples/_temp/features/ - -If you'd like to use the Python wrapper for extracting features, check out the [layer visualization notebook](http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/filter_visualization.ipynb). - -Clean Up --------- - -Let's remove the temporary directory now. - - rm -r examples/_temp diff --git a/docs/getting_pretrained_models.md b/docs/getting_pretrained_models.md index 79b78581..5df2bd4d 100644 --- a/docs/getting_pretrained_models.md +++ b/docs/getting_pretrained_models.md @@ -8,7 +8,8 @@ layout: default Note that unlike Caffe itself, these models are licensed for **academic research / non-commercial use only**. If you have any questions, please get in touch with us. -This page will be updated as more models become available. +*UPDATE* July 2014: we are actively working on a service for hosting user-uploaded model definition and trained weight files. +Soon, the community will be able to easily contribute different architectures! ### ImageNet @@ -28,4 +29,6 @@ This page will be updated as more models become available. **R-CNN (ILSVRC13)**: The pure Caffe instantiation of the [R-CNN](https://github.com/rbgirshick/rcnn) model for ILSVRC13 detection. Download the model (230.8MB) by running `examples/imagenet/get_caffe_rcnn_imagenet_model.sh` from the Caffe root directory. This model was made by transplanting the R-CNN SVM classifiers into a `fc-rcnn` classification layer, provided here as an off-the-shelf Caffe detector. Try the [detection example](http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/detection.ipynb) to see it in action. For the full details, refer to the R-CNN site. *N.B. For research purposes, make use of the official R-CNN package and not this example.* +### Auxiliary Data + Additionally, you will probably eventually need some auxiliary data (mean image, synset list, etc.): run `data/ilsvrc12/get_ilsvrc_aux.sh` from the root directory to obtain it. diff --git a/docs/imagenet_training.md b/docs/imagenet_training.md deleted file mode 100644 index f628f795..00000000 --- a/docs/imagenet_training.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -layout: default -title: Caffe ---- - -Yangqing's Recipe on Brewing ImageNet -===================================== - - "All your braincells are belong to us." - - Caffeine - -We are going to describe a reference implementation for the approach first proposed by Krizhevsky, Sutskever, and Hinton in their [NIPS 2012 paper](http://books.nips.cc/papers/files/nips25/NIPS2012_0534.pdf). Since training the whole model takes some time and energy, we provide a model, trained in the same way as we describe here, to help fight global warming. If you would like to simply use the pretrained model, check out the [Pretrained ImageNet](getting_pretrained_models.html) page. *Note that the pretrained model is for academic research / non-commercial use only*. - -To clarify, by ImageNet we actually mean the ILSVRC12 challenge, but you can easily train on the whole of ImageNet as well, just with more disk space, and a little longer training time. - -(If you don't get the quote, visit [Yann LeCun's fun page](http://yann.lecun.com/ex/fun/). - -Data Preparation ----------------- - -We assume that you already have downloaded the ImageNet training data and validation data, and they are stored on your disk like: - - /path/to/imagenet/train/n01440764/n01440764_10026.JPEG - /path/to/imagenet/val/ILSVRC2012_val_00000001.JPEG - -You will first need to prepare some auxiliary data for training. This data can be downloaded by: - - cd $CAFFE_ROOT/data/ilsvrc12/ - ./get_ilsvrc_aux.sh - -The training and validation input are described in `train.txt` and `val.txt` as text listing all the files and their labels. Note that we use a different indexing for labels than the ILSVRC devkit: we sort the synset names in their ASCII order, and then label them from 0 to 999. See `synset_words.txt` for the synset/name mapping. - -You may want to resize the images to 256x256 in advance. By default, we do not explicitly do this because in a cluster environment, one may benefit from resizing images in a parallel fashion, using mapreduce. For example, Yangqing used his lightedweighted [mincepie](https://github.com/Yangqing/mincepie) package to do mapreduce on the Berkeley cluster. If you would things to be rather simple and straightforward, you can also use shell commands, something like: - - for name in /path/to/imagenet/val/*.JPEG; do - convert -resize 256x256\! $name $name - done - -Go to `$CAFFE_ROOT/examples/imagenet/` for the rest of this guide. - -Take a look at `create_imagenet.sh`. Set the paths to the train and val dirs as needed, and set "RESIZE=true" to resize all images to 256x256 if you haven't resized the images in advance. Now simply create the leveldbs with `./create_imagenet.sh`. Note that `imagenet_train_leveldb` and `imagenet_val_leveldb` should not exist before this execution. It will be created by the script. `GLOG_logtostderr=1` simply dumps more information for you to inspect, and you can safely ignore it. - -Compute Image Mean ------------------- - -The model requires us to subtract the image mean from each image, so we have to compute the mean. `tools/compute_image_mean.cpp` implements that - it is also a good example to familiarize yourself on how to manipulate the multiple components, such as protocol buffers, leveldbs, and logging, if you are not familiar with them. Anyway, the mean computation can be carried out as: - - ./make_imagenet_mean.sh - -which will make `data/ilsvrc12/imagenet_mean.binaryproto`. - -Network Definition ------------------- - -The network definition follows strictly the one in Krizhevsky et al. You can find the detailed definition at `examples/imagenet/imagenet_train.prototxt`. Note the paths in the data layer - if you have not followed the exact paths in this guide you will need to change the following lines: - - source: "ilvsrc12_train_leveldb" - mean_file: "../../data/ilsvrc12/imagenet_mean.binaryproto" - -to point to your own leveldb and image mean. Likewise, do the same for `examples/imagenet/imagenet_val.prototxt`. - -If you look carefully at `imagenet_train.prototxt` and `imagenet_val.prototxt`, you will notice that they are largely the same, with the only difference being the data layer sources, and the last layer: in training, we will be using a `softmax_loss` layer to compute the loss function and to initialize the backpropagation, while in validation we will be using an `accuracy` layer to inspect how well we do in terms of accuracy. - -We will also lay out a protocol buffer for running the solver. Let's make a few plans: -* We will run in batches of 256, and run a total of 4,500,000 iterations (about 90 epochs). -* For every 1,000 iterations, we test the learned net on the validation data. -* We set the initial learning rate to 0.01, and decrease it every 100,000 iterations (about 20 epochs). -* Information will be displayed every 20 epochs. -* The network will be trained with momentum 0.9 and a weight decay of 0.0005. -* For every 10,000 iterations, we will take a snapshot of the current status. - -Sound good? This is implemented in `examples/imagenet/imagenet_solver.prototxt`. Again, you will need to change the first two lines: - - train_net: "imagenet_train.prototxt" - test_net: "imagenet_val.prototxt" - -to point to the actual path if you have changed them. - -Training ImageNet ------------------ - -Ready? Let's train. - - ./train_imagenet.sh - -Sit back and enjoy! On my K20 machine, every 20 iterations take about 36 seconds to run, so effectively about 7 ms per image for the full forward-backward pass. About 2.5 ms of this is on forward, and the rest is backward. If you are interested in dissecting the computation time, you can look at `examples/net_speed_benchmark.cpp`, but it was written purely for debugging purpose, so you may need to figure a few things out yourself. - -Resume Training? ----------------- - -We all experience times when the power goes out, or we feel like rewarding ourself a little by playing Battlefield (does someone still remember Quake?). Since we are snapshotting intermediate results during training, we will be able to resume from snapshots. This can be done as easy as: - - ./resume_training.sh - -where in the script `caffe_imagenet_train_1000.solverstate` is the solver state snapshot that stores all necessary information to recover the exact solver state (including the parameters, momentum history, etc). - -Parting Words -------------- - -Hope you liked this recipe! Many researchers have gone further since the ILSVRC 2012 challenge, changing the network architecture and/or finetuning the various parameters in the network. The recent ILSVRC 2013 challenge suggests that there are quite some room for improvement. **Caffe allows one to explore different network choices more easily, by simply writing different prototxt files** - isn't that exciting? - -And since now you have a trained network, check out how to use it: [Running Pretrained ImageNet](getting_pretrained_models.html). This time we will use Python, but if you have wrappers for other languages, please kindly send a pull request! diff --git a/docs/index.md b/docs/index.md index 03b583d4..6ffab7a0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,14 +7,16 @@ Caffe is a deep learning framework developed with cleanliness, readability, and It was created by [Yangqing Jia](http://daggerfs.com), and is in active development by the Berkeley Vision and Learning Center ([BVLC](http://bvlc.eecs.berkeley.edu)) and by community contributors. Caffe is released under the [BSD 2-Clause license](https://github.com/BVLC/caffe/blob/master/LICENSE). -## Why +Check out our web image classification [demo](http://demo.caffe.berkeleyvision.org)! + +## Why use Caffe? **Clean architecture** enables rapid deployment. Networks are specified in simple config files, with no hard-coded parameters in the code. -Switching between CPU and GPU code is as simple as setting a flag -- so models can be trained on a GPU machine, and then used on commodity clusters. +Switching between CPU and GPU is as simple as setting a flag -- so models can be trained on a GPU machine, and then used on commodity clusters. **Readable & modifiable implementation** fosters active development. -In Caffe's first six months, it has been forked by over 300 developers on Github, and many have contributed significant changes. +In Caffe's first six months, it has been forked by over 300 developers on Github, and many have pushed significant changes. **Speed** makes Caffe perfect for industry use. Caffe can process over **40M images per day** with a single NVIDIA K40 or Titan GPU\*. @@ -29,29 +31,34 @@ There is an active discussion and support community on [Github](https://github.c Consult performance [details](/performance_hardware.html). </p> -## How - -* [Introductory slides](http://dl.caffe.berkeleyvision.org/caffe-presentation.pdf): slides about the Caffe architecture, *updated 03/14*. -* [ACM MM paper](http://ucb-icsi-vision-group.github.io/caffe-paper/caffe.pdf): a 4-page report for the ACM Multimedia Open Source competition. -* [Installation instructions](/installation.html): tested on Ubuntu, Red Hat, OS X. -* [Pre-trained models](/getting_pretrained_models.html): BVLC provides ready-to-use models for non-commercial use. -* [Development](/development.html): Guidelines for development and contributing to Caffe. - -### Tutorials and Examples - -* [Image Classification \[notebook\]][imagenet_classification]: classify images with the pretrained ImageNet model by the Python interface. -* [Detection \[notebook\]][detection]: run a pretrained model as a detector in Python. -* [Visualizing Features and Filters \[notebook\]][visualizing_filters]: extracting features and visualizing trained filters with an example image, viewed layer-by-layer. -* [Editing Model Parameters \[notebook\]][net_surgery]: how to do net surgery and manually change model parameters. -* [LeNet / MNIST Demo](/mnist.html): end-to-end training and testing of LeNet on MNIST. -* [CIFAR-10 Demo](/cifar10.html): training and testing on the CIFAR-10 data. -* [Training ImageNet](/imagenet_training.html): recipe for end-to-end training of an ImageNet classifier. -* [Feature extraction with C++](/feature_extraction.html): feature extraction using pre-trained model. - -[imagenet_classification]: http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/imagenet_classification.ipynb -[detection]: http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/detection.ipynb -[visualizing_filters]: http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/filter_visualization.ipynb -[net_surgery]: http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/net_surgery.ipynb +## Documentation + +- [Introductory slides](http://dl.caffe.berkeleyvision.org/caffe-presentation.pdf)<br /> +Slides about the Caffe architecture, *updated 03/14*. +- [ACM MM paper](http://ucb-icsi-vision-group.github.io/caffe-paper/caffe.pdf)<br /> +A 4-page report for the ACM Multimedia Open Source competition. +- [Installation instructions](/installation.html)<br /> +Tested on Ubuntu, Red Hat, OS X. +* [Pre-trained models](/getting_pretrained_models.html)<br /> +BVLC provides ready-to-use models for non-commercial use. +* [Development](/development.html)<br /> +Guidelines for development and contributing to Caffe. + +### Examples + +{% for page in site.pages %} +{% if page.category == 'example' %} +- <div><a href="{{page.url}}">{{page.title}}</a><br />{{page.description}}</div> +{% endif %} +{% endfor %} + +### Notebook examples + +{% for page in site.pages %} +{% if page.category == 'notebook' %} +- <div><a href="http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/{{page.original_path}}">{{page.title}}</a><br />{{page.description}}</div> +{% endif %} +{% endfor %} ## Citing Caffe diff --git a/docs/javascripts/scale.fix.js b/docs/javascripts/scale.fix.js deleted file mode 100644 index 08716c00..00000000 --- a/docs/javascripts/scale.fix.js +++ /dev/null @@ -1,20 +0,0 @@ -fixScale = function(doc) { - - var addEvent = 'addEventListener', - type = 'gesturestart', - qsa = 'querySelectorAll', - scales = [1, 1], - meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; - - function fix() { - meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; - doc.removeEventListener(type, fix, true); - } - - if ((meta = meta[meta.length - 1]) && addEvent in doc) { - fix(); - scales = [.25, 1.6]; - doc[addEvent](type, fix, true); - } - -};
\ No newline at end of file diff --git a/docs/mnist.md b/docs/mnist.md deleted file mode 100644 index 9a9b46a4..00000000 --- a/docs/mnist.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -layout: default -title: Caffe ---- - -Training MNIST with Caffe -================ - -We will assume that you have caffe successfully compiled. If not, please refer to the [Installation page](installation.html). In this tutorial, we will assume that your caffe installation is located at `CAFFE_ROOT`. - -Prepare Datasets ----------------- - -You will first need to download and convert the data format from the MNIST website. To do this, simply run the following commands: - - cd $CAFFE_ROOT/data/mnist - ./get_mnist.sh - cd $CAFFE_ROOT/examples/mnist - ./create_mnist.sh - -If it complains that `wget` or `gunzip` are not installed, you need to install them respectively. After running the script there should be two datasets, `mnist-train-leveldb`, and `mnist-test-leveldb`. - -LeNet: the MNIST Classification Model -------------------------------------- -Before we actually run the training program, let's explain what will happen. We will use the [LeNet](http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf) network, which is known to work well on digit classification tasks. We will use a slightly different version from the original LeNet implementation, replacing the sigmoid activations with Rectified Linear Unit (ReLU) activations for the neurons. - -The design of LeNet contains the essence of CNNs that are still used in larger models such as the ones in ImageNet. In general, it consists of a convolutional layer followed by a pooling layer, another convolution layer followed by a pooling layer, and then two fully connected layers similar to the conventional multilayer perceptrons. We have defined the layers in `CAFFE_ROOT/data/lenet.prototxt`. - -If you would like to read about step-by-step instruction on how the protobuf definitions are written, see [MNIST: Define the Network](mnist_prototxt.html) and [MNIST: Define the Solver](mnist_solver_prototxt.html)?. - -Training and Testing the Model ------------------------------- - -Training the model is simple after you have written the network definition protobuf and solver protobuf files. Simply run `train_mnist.sh`, or the following command directly: - - cd $CAFFE_ROOT/examples/mnist - ./train_lenet.sh - -`train_lenet.sh` is a simple script, but here are a few explanations: `GLOG_logtostderr=1` is the google logging flag that prints all the logging messages directly to stderr. The main tool for training is `train_net.bin`, with the solver protobuf text file as its argument. - -When you run the code, you will see a lot of messages flying by like this: - - I1203 net.cpp:66] Creating Layer conv1 - I1203 net.cpp:76] conv1 <- data - I1203 net.cpp:101] conv1 -> conv1 - I1203 net.cpp:116] Top shape: 20 24 24 - I1203 net.cpp:127] conv1 needs backward computation. - -These messages tell you the details about each layer, its connections and its output shape, which may be helpful in debugging. After the initialization, the training will start: - - I1203 net.cpp:142] Network initialization done. - I1203 solver.cpp:36] Solver scaffolding done. - I1203 solver.cpp:44] Solving LeNet - -Based on the solver setting, we will print the training loss function every 100 iterations, and test the network every 1000 iterations. You will see messages like this: - - I1203 solver.cpp:204] Iteration 100, lr = 0.00992565 - I1203 solver.cpp:66] Iteration 100, loss = 0.26044 - ... - I1203 solver.cpp:84] Testing net - I1203 solver.cpp:111] Test score #0: 0.9785 - I1203 solver.cpp:111] Test score #1: 0.0606671 - -For each training iteration, `lr` is the learning rate of that iteration, and `loss` is the training function. For the output of the testing phase, score 0 is the accuracy, and score 1 is the testing loss function. - -And after a few minutes, you are done! - - I1203 solver.cpp:84] Testing net - I1203 solver.cpp:111] Test score #0: 0.9897 - I1203 solver.cpp:111] Test score #1: 0.0324599 - I1203 solver.cpp:126] Snapshotting to lenet_iter_10000 - I1203 solver.cpp:133] Snapshotting solver state to lenet_iter_10000.solverstate - I1203 solver.cpp:78] Optimization Done. - -The final model, stored as a binary protobuf file, is stored at - - lenet_iter_10000 - -which you can deploy as a trained model in your application, if you are training on a real-world application dataset. - -Um... How about GPU training? ------------------------------ - -You just did! All the training was carried out on the GPU. In fact, if you would like to do training on CPU, you can simply change one line in `lenet_solver.prototxt`: - - # solver mode: CPU or GPU - solver_mode: CPU - -and you will be using CPU for training. Isn't that easy? - -MNIST is a small dataset, so training with GPU does not really introduce too much benefit due to communication overheads. On larger datasets with more complex models, such as ImageNet, the computation speed difference will be more significant. diff --git a/docs/mnist_prototxt.md b/docs/mnist_prototxt.md deleted file mode 100644 index aaff2b00..00000000 --- a/docs/mnist_prototxt.md +++ /dev/null @@ -1,153 +0,0 @@ ---- -layout: default -title: Caffe ---- - -Define the MNIST Network -========================= - -This page explains the prototxt file `lenet_train.prototxt` used in the MNIST demo. We assume that you are familiar with [Google Protobuf](https://developers.google.com/protocol-buffers/docs/overview), and assume that you have read the protobuf definitions used by Caffe, which can be found at [src/caffe/proto/caffe.proto](https://github.com/Yangqing/caffe/blob/master/src/caffe/proto/caffe.proto). - -Specifically, we will write a `caffe::NetParameter` (or in python, `caffe.proto.caffe_pb2.NetParameter`) protubuf. We will start by giving the network a name: - - name: "LeNet" - -Writing the Data Layer ----------------------- -Currently, we will read the MNIST data from the leveldb we created earlier in the demo. This is defined by a data layer: - - layers { - name: "mnist" - type: DATA - data_param { - source: "mnist-train-leveldb" - batch_size: 64 - scale: 0.00390625 - } - top: "data" - top: "label" - } - -Specifically, this layer has name `mnist`, type `data`, and it reads the data from the given leveldb source. We will use a batch size of 64, and scale the incoming pixels so that they are in the range \[0,1\). Why 0.00390625? It is 1 divided by 256. And finally, this layer produces two blobs, one is the `data` blob, and one is the `label` blob. - -Writing the Convolution Layer --------------------------------------------- -Let's define the first convolution layer: - - layers { - name: "conv1" - type: CONVOLUTION - blobs_lr: 1. - blobs_lr: 2. - convolution_param { - num_output: 20 - kernelsize: 5 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - } - } - bottom: "data" - top: "conv1" - } - -This layer takes the `data` blob (it is provided by the data layer), and produces the `conv1` layer. It produces outputs of 20 channels, with the convolutional kernel size 5 and carried out with stride 1. - -The fillers allow us to randomly initialize the value of the weights and bias. For the weight filler, we will use the `xavier` algorithm that automatically determines the scale of initialization based on the number of input and output neurons. For the bias filler, we will simply initialize it as constant, with the default filling value 0. - -`blobs_lr` are the learning rate adjustments for the layer's learnable parameters. In this case, we will set the weight learning rate to be the same as the learning rate given by the solver during runtime, and the bias learning rate to be twice as large as that - this usually leads to better convergence rates. - -Writing the Pooling Layer -------------------------- -Phew. Pooling layers are actually much easier to define: - - layers { - name: "pool1" - type: POOLING - pooling_param { - kernel_size: 2 - stride: 2 - pool: MAX - } - bottom: "conv1" - top: "pool1" - } - -This says we will perform max pooling with a pool kernel size 2 and a stride of 2 (so no overlapping between neighboring pooling regions). - -Similarly, you can write up the second convolution and pooling layers. Check `data/lenet.prototxt` for details. - -Writing the Fully Connected Layer ----------------------------------- -Writing a fully connected layer is also simple: - - layers { - name: "ip1" - type: INNER_PRODUCT - blobs_lr: 1. - blobs_lr: 2. - inner_product_param { - num_output: 500 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - } - } - bottom: "pool2" - top: "ip1" - } - -This defines a fully connected layer (for some legacy reason, Caffe calls it an `innerproduct` layer) with 500 outputs. All other lines look familiar, right? - -Writing the ReLU Layer ----------------------- -A ReLU Layer is also simple: - - layers { - name: "relu1" - type: RELU - bottom: "ip1" - top: "ip1" - } - -Since ReLU is an element-wise operation, we can do *in-place* operations to save some memory. This is achieved by simply giving the same name to the bottom and top blobs. Of course, do NOT use duplicated blob names for other layer types! - -After the ReLU layer, we will write another innerproduct layer: - - layers { - name: "ip2" - type: INNER_PRODUCT - blobs_lr: 1. - blobs_lr: 2. - inner_product_param { - num_output: 10 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - } - } - bottom: "ip1" - top: "ip2" - } - -Writing the Loss Layer -------------------------- -Finally, we will write the loss! - - layers { - name: "loss" - type: SOFTMAX_LOSS - bottom: "ip2" - bottom: "label" - } - -The `softmax_loss` layer implements both the softmax and the multinomial logistic loss (that saves time and improves numerical stability). It takes two blobs, the first one being the prediction and the second one being the `label` provided by the data layer (remember it?). It does not produce any outputs - all it does is to compute the loss function value, report it when backpropagation starts, and initiates the gradient with respect to `ip2`. This is where all magic starts. - -Now that we have demonstrated how to write the MNIST layer definition prototxt, maybe check out [how we write a solver prototxt](mnist_solver_prototxt.html)? diff --git a/docs/mnist_solver_prototxt.md b/docs/mnist_solver_prototxt.md deleted file mode 100644 index aa3578f1..00000000 --- a/docs/mnist_solver_prototxt.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -layout: default -title: Caffe ---- - -Define the MNIST Solver -======================= - -The page is under construction. For now, check out the comments in the solver prototxt file, which explains each line in the prototxt: - - # The training protocol buffer definition - train_net: "lenet_train.prototxt" - # The testing protocol buffer definition - test_net: "lenet_test.prototxt" - # test_iter specifies how many forward passes the test should carry out. - # In the case of MNIST, we have test batch size 100 and 100 test iterations, - # covering the full 10,000 testing images. - test_iter: 100 - # Carry out testing every 500 training iterations. - test_interval: 500 - # The base learning rate, momentum and the weight decay of the network. - base_lr: 0.01 - momentum: 0.9 - weight_decay: 0.0005 - # The learning rate policy - lr_policy: "inv" - gamma: 0.0001 - power: 0.75 - # Display every 100 iterations - display: 100 - # The maximum number of iterations - max_iter: 10000 - # snapshot intermediate results - snapshot: 5000 - snapshot_prefix: "lenet" - # solver mode: 0 for CPU and 1 for GPU - solver_mode: 1 diff --git a/docs/stylesheets/styles.css b/docs/stylesheets/styles.css index 5862c6c2..2dbedb8a 100644 --- a/docs/stylesheets/styles.css +++ b/docs/stylesheets/styles.css @@ -42,7 +42,7 @@ h3 { } h4, h5, h6 { - font-family: Times, serif; + font-family: 'PT Serif', serif; font-weight: 700; } @@ -68,12 +68,11 @@ strong { } ul { - list-style: inside; padding-left: 25px; } ol { - list-style: decimal inside; + list-style: decimal; padding-left: 20px; } @@ -129,7 +128,6 @@ p img { } /* Code blocks */ - code, pre { font-family: monospace; color:#000; @@ -149,7 +147,6 @@ pre { /* Tables */ - table { width:100%; } @@ -161,7 +158,7 @@ table { } th { - font-family: 'Arvo', Helvetica, Arial, sans-serif; + font-family: 'Open Sans', sans-serif; font-size: 18px; font-weight: normal; padding: 10px; @@ -184,21 +181,11 @@ td { /* Header */ header { - background-color: #171717; - color: #FDFDFB; width:170px; float:left; position:fixed; - border: 1px solid #000; - -webkit-border-top-right-radius: 4px; - -webkit-border-bottom-right-radius: 4px; - -moz-border-radius-topright: 4px; - -moz-border-radius-bottomright: 4px; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; padding: 12px 25px 22px 50px; margin: 24px 25px 0 0; - -webkit-font-smoothing: antialiased; } p.header { @@ -206,23 +193,12 @@ p.header { } h1.header { - /*font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;*/ font-size: 30px; font-weight: 300; line-height: 1.3em; - border-bottom: none; margin-top: 0; } - -h1.header, a.header, a.name, header a{ - color: #fff; -} - -a.header { - text-decoration: underline; -} - a.name { white-space: nowrap; } @@ -239,38 +215,19 @@ header li { margin-bottom: 12px; line-height: 1em; padding: 6px 6px 6px 7px; - - background: #AF0011; - background: -moz-linear-gradient(top, #AF0011 0%, #820011 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); - background: -webkit-linear-gradient(top, #AF0011 0%,#820011 100%); - background: -o-linear-gradient(top, #AF0011 0%,#820011 100%); - background: -ms-linear-gradient(top, #AF0011 0%,#820011 100%); - background: linear-gradient(top, #AF0011 0%,#820011 100%); - + background: #c30000; border-radius:4px; - border:1px solid #0D0D0D; - - -webkit-box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1); - box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1); - + border:1px solid #555; } header li:hover { - background: #C3001D; - background: -moz-linear-gradient(top, #C3001D 0%, #950119 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); - background: -webkit-linear-gradient(top, #C3001D 0%,#950119 100%); - background: -o-linear-gradient(top, #C3001D 0%,#950119 100%); - background: -ms-linear-gradient(top, #C3001D 0%,#950119 100%); - background: linear-gradient(top, #C3001D 0%,#950119 100%); + background: #dd0000; } a.buttons { - -webkit-font-smoothing: antialiased; - background: url(../images/arrow-down.png) no-repeat; + color: #fff; + text-decoration: none; font-weight: normal; - text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0; padding: 2px 2px 2px 22px; height: 30px; } @@ -280,12 +237,6 @@ a.github { background-size: 15%; } -a.buttons:hover { - color: #fff; - text-decoration: none; -} - - /* Section - for main page content */ section { |