summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/installation.md16
-rw-r--r--docs/tutorial/net_layer_blob.md4
-rw-r--r--examples/finetune_flickr_style/readme.md14
-rw-r--r--examples/mnist/readme.md17
-rw-r--r--models/finetune_flickr_style/readme.md11
-rw-r--r--python/requirements.txt13
-rw-r--r--src/caffe/solver.cpp2
7 files changed, 40 insertions, 37 deletions
diff --git a/docs/installation.md b/docs/installation.md
index dbf73d2c..207e17d1 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -18,7 +18,7 @@ Caffe depends on several software packages.
* [CUDA](https://developer.nvidia.com/cuda-zone) library version 6.5 (recommended), 6.0, 5.5, or 5.0 and the latest driver version for CUDA 6 or 319.* for CUDA 5 (and NOT 331.*)
* [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) (provided via ATLAS, MKL, or OpenBLAS).
* [OpenCV](http://opencv.org/).
-* [Boost](http://www.boost.org/) (>= 1.55, although only 1.55 is tested)
+* [Boost](http://www.boost.org/) (>= 1.55, although only 1.55 and 1.56 are tested)
* `glog`, `gflags`, `protobuf`, `leveldb`, `snappy`, `hdf5`, `lmdb`
* For the Python wrapper
* `Python 2.7`, `numpy (>= 1.7)`, boost-provided `boost.python`
@@ -59,7 +59,7 @@ The main requirements are `numpy` and `boost.python` (provided by boost). `panda
You can install the dependencies with
- pip install -r /path/to/caffe/python/requirements.txt
+ for req in $(cat requirements.txt); do sudo pip install $req; done
but we highly recommend first installing the [Anaconda](https://store.continuum.io/cshop/anaconda/) Python distribution, which provides most of the necessary packages, as well as the `hdf5` library dependency.
@@ -141,11 +141,13 @@ Do `brew edit opencv` and change the lines that look like the two lines below to
**NOTE**: We find that everything compiles successfully if `$LD_LIBRARY_PATH` is not set at all, and `$DYLD_FALLBACK_LIBRARY_PATH` is set to to provide CUDA, Python, and other relevant libraries (e.g. `/usr/local/cuda/lib:$HOME/anaconda/lib:/usr/local/lib:/usr/lib`).
In other `ENV` settings, things may not work as expected.
+**NOTE**: There is currently a conflict between boost 1.56 and CUDA in some configurations. Check the [conflict description](https://github.com/BVLC/caffe/issues/1193#issuecomment-57491906) and try downgrading to 1.55.
+
#### 10.8-specific Instructions
Simply run the following:
- brew install --build-from-source --with-python boost
+ brew install --build-from-source boost boost-python
brew install --with-python protobuf
for x in snappy leveldb gflags glog szip lmdb homebrew/science/opencv; do brew install $x; done
@@ -180,22 +182,22 @@ For each of these formulas, `brew edit FORMULA`, and add the ENV definitions as
To edit the formulae in turn, run
- for x in snappy leveldb protobuf gflags glog szip boost lmdb homebrew/science/opencv; do brew edit $x; done
+ for x in snappy leveldb protobuf gflags glog szip boost boost-python lmdb homebrew/science/opencv; do brew edit $x; done
After this, run
for x in snappy leveldb gflags glog szip lmdb homebrew/science/opencv; do brew uninstall $x; brew install --build-from-source --fresh -vd $x; done
brew uninstall protobuf; brew install --build-from-source --with-python --fresh -vd protobuf
- brew install --build-from-source --with-python --fresh -vd boost
+ brew install --build-from-source --fresh -vd boost boost-python
**Note** that `brew install --build-from-source --fresh -vd boost` is fine if you do not need the Caffe Python wrapper.
**Note** that the HDF5 dependency is provided by Anaconda Python in this case.
If you're not using Anaconda, include `hdf5` in the list above.
-**Note** that in order to build the caffe python wrappers you must install boost using the --with-python option:
+**Note** that in order to build the Caffe Python wrappers you must install `boost` and `boost-python`:
- brew install --build-from-source --with-python --fresh -vd boost
+ brew install --build-from-source --fresh -vd boost boost-python
**Note** that Homebrew maintains itself as a separate git repository and making the above `brew edit FORMULA` changes will change files in your local copy of homebrew's master branch. By default, this will prevent you from updating Homebrew using `brew update`, as you will get an error message like the following:
diff --git a/docs/tutorial/net_layer_blob.md b/docs/tutorial/net_layer_blob.md
index b500aaa6..1f0966f8 100644
--- a/docs/tutorial/net_layer_blob.md
+++ b/docs/tutorial/net_layer_blob.md
@@ -26,7 +26,7 @@ Note that although we have designed blobs with its dimensions corresponding to i
Caffe operations are general with respect to the channel dimension / K. Grayscale and hyperspectral imagery are fine. Caffe can likewise model and process arbitrary vectors in blobs with singleton. That is, the shape of blob holding 1000 vectors of 16 feature dimensions is 1000 x 16 x 1 x 1.
-Parameter blob dimensions vary according to the type and configuration of the layer. For a convolution layer with 96 filters of 11 x 11 spatial dimension and 3 inputs the blob is 96 x 3 x 11 x 11. For an inner product / fully-connected layer with 1000 output channels and 1024 input channels the parameter blob is 1 x 1 x 1000 x 4096.
+Parameter blob dimensions vary according to the type and configuration of the layer. For a convolution layer with 96 filters of 11 x 11 spatial dimension and 3 inputs the blob is 96 x 3 x 11 x 11. For an inner product / fully-connected layer with 1000 output channels and 1024 input channels the parameter blob is 1 x 1 x 1000 x 1024.
For custom data it may be necessary to hack your own input preparation tool or data layer. However once your data is in your job is done. The modularity of layers accomplishes the rest of the work for you.
@@ -85,7 +85,7 @@ Developing custom layers requires minimal effort by the compositionality of the
The net jointly defines a function and its gradient by composition and auto-differentiation. The composition of every layer's output computes the function to do a given task, and the composition of every layer's backward computes the gradient from the loss to learn the task. Caffe models are end-to-end machine learning engines.
-The net is a set of layers connected in a computation graph -- a DAG / directed acyclic graph to be exact. Caffe does all the bookkeeping for any DAG of layers to ensure correctness of the forward and backward passes. A typical net begins with a data layer that loads from disk and ends with a loss layer that computes the objective for a task such as classification or reconstruction.
+The net is a set of layers connected in a computation graph -- a directed acyclic graph (DAG) to be exact. Caffe does all the bookkeeping for any DAG of layers to ensure correctness of the forward and backward passes. A typical net begins with a data layer that loads from disk and ends with a loss layer that computes the objective for a task such as classification or reconstruction.
The net is defined as a set of layers and their connections in a plaintext modeling language.
A simple logistic regression classifier
diff --git a/examples/finetune_flickr_style/readme.md b/examples/finetune_flickr_style/readme.md
index 4220102e..ecb9d3d2 100644
--- a/examples/finetune_flickr_style/readme.md
+++ b/examples/finetune_flickr_style/readme.md
@@ -13,14 +13,14 @@ Let's fine-tune the BVLC-distributed CaffeNet model on a different dataset, [Fli
## Explanation
-The Flickr-sourced images of the Style dataset are visually very similar to the ImageNet dataset, on which the `caffe_reference_imagenet_model` was trained.
+The Flickr-sourced images of the Style dataset are visually very similar to the ImageNet dataset, on which the `bvlc_reference_caffenet` was trained.
Since that model works well for object category classification, we'd like to use it architecture for our style classifier.
We also only have 80,000 images to train on, so we'd like to start with the parameters learned on the 1,000,000 ImageNet images, and fine-tune as needed.
If we give provide the `weights` argument to the `caffe train` command, the pretrained weights will be loaded into our model, matching layers by name.
Because we are predicting 20 classes instead of a 1,000, we do need to change the last layer in the model.
Therefore, we change the name of the last layer from `fc8` to `fc8_flickr` in our prototxt.
-Since there is no layer named that in the `caffe_reference_imagenet_model`, that layer will begin training with random weights.
+Since there is no layer named that in the `bvlc_reference_caffenet`, that layer will begin training with random weights.
We will also decrease the overall learning rate `base_lr` in the solver prototxt, but boost the `blobs_lr` on the newly introduced layer.
The idea is to have the rest of the model change very slowly with new data, but let the new layer learn fast.
@@ -34,7 +34,7 @@ All steps are to be done from the caffe root directory.
The dataset is distributed as a list of URLs with corresponding labels.
Using a script, we will download a small subset of the data and split it into train and val sets.
- caffe % ./models/finetune_flickr_style/assemble_data.py -h
+ caffe % ./examples/finetune_flickr_style/assemble_data.py -h
usage: assemble_data.py [-h] [-s SEED] [-i IMAGES] [-w WORKERS]
Download a subset of Flickr Style to a directory
@@ -48,12 +48,11 @@ Using a script, we will download a small subset of the data and split it into tr
num workers used to download images. -x uses (all - x)
cores.
- caffe % python models/finetune_flickr_style/assemble_data.py --workers=-1 --images=2000 --seed 831486
+ caffe % python examples/finetune_flickr_style/assemble_data.py --workers=-1 --images=2000 --seed 831486
Downloading 2000 images with 7 workers...
Writing train/val for 1939 successfully downloaded images.
This script downloads images and writes train/val file lists into `data/flickr_style`.
-With this random seed there are 1,557 train images and 382 test images.
The prototxts in this example assume this, and also assume the presence of the ImageNet mean file (run `get_ilsvrc_aux.sh` from `data/ilsvrc12` to obtain this if you haven't yet).
We'll also need the ImageNet-trained model, which you can obtain by running `./scripts/download_model_binary.py models/bvlc_reference_caffenet`.
@@ -106,7 +105,8 @@ Now we can train! (You can fine-tune in CPU mode by leaving out the `-gpu` flag.
I0828 22:23:17.438894 11510 solver.cpp:302] Test net output #0: accuracy = 0.2356
Note how rapidly the loss went down. Although the 23.5% accuracy is only modest, it was achieved in only 1000, and evidence that the model is starting to learn quickly and well.
-Once the model is fully fine-tuned on the whole training set over 100,000 iterations the final validation accuracy is 91.64%. This takes ~7 hours in Caffe on a K40 GPU.
+Once the model is fully fine-tuned on the whole training set over 100,000 iterations the final validation accuracy is 39.16%.
+This takes ~7 hours in Caffe on a K40 GPU.
For comparison, here is how the loss goes down when we do not start with a pre-trained model:
@@ -155,7 +155,7 @@ Now try fine-tuning to your own tasks and data!
## Trained model
-We provide a model trained on all 80K images, with final accuracy of 98%.
+We provide a model trained on all 80K images, with final accuracy of 39%.
Simply do `./scripts/download_model_binary.py models/finetune_flickr_style` to obtain it.
## License
diff --git a/examples/mnist/readme.md b/examples/mnist/readme.md
index 1f8a8696..ef7f5da6 100644
--- a/examples/mnist/readme.md
+++ b/examples/mnist/readme.md
@@ -1,12 +1,12 @@
---
-title: MNIST Tutorial
-description: Train and test "LeNet" on MNIST data.
+title: LeNet MNIST Tutorial
+description: Train and test "LeNet" on the MNIST handwritten digit data.
category: example
include_in_docs: true
priority: 1
---
-# Training MNIST with Caffe
+# Training LeNet on 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`.
@@ -14,10 +14,9 @@ We will assume that you have Caffe successfully compiled. If not, please refer t
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
+ cd $CAFFE_ROOT
+ ./data/mnist/get_mnist.sh
+ ./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_lmdb`, and `mnist_test_lmdb`.
@@ -228,8 +227,8 @@ Check out the comments explaining each line in the prototxt `$CAFFE_ROOT/example
Training the model is simple after you have written the network definition protobuf and solver protobuf files. Simply run `train_lenet.sh`, or the following command directly:
- cd $CAFFE_ROOT/examples/mnist
- ./train_lenet.sh
+ cd $CAFFE_ROOT
+ ./examples/mnist/train_lenet.sh
`train_lenet.sh` is a simple script, but here is a quick explanation: the main tool for training is `caffe` with action `train` and the solver protobuf text file as its argument.
diff --git a/models/finetune_flickr_style/readme.md b/models/finetune_flickr_style/readme.md
index c08485f7..d2a8a95f 100644
--- a/models/finetune_flickr_style/readme.md
+++ b/models/finetune_flickr_style/readme.md
@@ -3,16 +3,17 @@ name: Finetuning CaffeNet on Flickr Style
caffemodel: finetune_flickr_style.caffemodel
caffemodel_url: http://dl.caffe.berkeleyvision.org/finetune_flickr_style.caffemodel
license: non-commercial
-sha1: 443ad95a61fb0b5cd3cee55951bcc1f299186b5e
-caffe_commit: 41751046f18499b84dbaf529f64c0e664e2a09fe
+sha1: b61b5cef7d771b53b0c488e78d35ccadc073e9cf
+caffe_commit: 737ea5e936821b5c69f9c3952d72693ae5843370
gist_id: 034c6ac3865563b69e60
---
This model is trained exactly as described in `docs/finetune_flickr_style/readme.md`, using all 80000 images.
-The final performance on the test set:
+The final performance:
- I0903 18:40:59.211707 11585 caffe.cpp:167] Loss: 0.407405
- I0903 18:40:59.211717 11585 caffe.cpp:179] accuracy = 0.9164
+ I1017 07:36:17.370688 31333 solver.cpp:228] Iteration 100000, loss = 0.757952
+ I1017 07:36:17.370730 31333 solver.cpp:247] Iteration 100000, Testing net (#0)
+ I1017 07:36:34.248730 31333 solver.cpp:298] Test net output #0: accuracy = 0.3916
## License
diff --git a/python/requirements.txt b/python/requirements.txt
index 5c076b66..4c35dcb0 100644
--- a/python/requirements.txt
+++ b/python/requirements.txt
@@ -1,14 +1,15 @@
Cython>=0.19.2
-h5py>=2.2.0
+numpy>=1.7.1
+scipy>=0.13.2
+scikit-image>=0.9.3
+scikit-learn>=0.14.1
+matplotlib>=1.3.1
ipython>=1.1.0
+h5py>=2.2.0
leveldb>=0.191
-matplotlib>=1.3.1
networkx>=1.8.1
nose>=1.3.0
-numpy>=1.7.1
pandas>=0.12.0
+python-dateutil>=1.4,<2
protobuf>=2.5.0
python-gflags>=2.0
-scikit-image>=0.9.3
-scikit-learn>=0.14.1
-scipy>=0.13.2
diff --git a/src/caffe/solver.cpp b/src/caffe/solver.cpp
index 5b8f0795..7f5d3d20 100644
--- a/src/caffe/solver.cpp
+++ b/src/caffe/solver.cpp
@@ -23,7 +23,7 @@ template <typename Dtype>
Solver<Dtype>::Solver(const string& param_file)
: net_() {
SolverParameter param;
- ReadProtoFromTextFile(param_file, &param);
+ ReadProtoFromTextFileOrDie(param_file, &param);
Init(param);
}