Lock the mex file to avoid Matlab crashes.

Commands like "clear all" and "clear function" causes segmentation faults or errors like these (especially after an 'init'):
 libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe/proto/caffe.proto
 libprotobuf FATAL google/protobuf/descriptor.cc:862] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
 [libprotobuf ERROR google/protobuf/message.cc:333] Type appears to be in generated pool but wasn't registered: caffe.LayerParameter
 Attempt to restart MATLAB?
To avoid these, lock the the mex file.
Added contrastive loss layer, associated tests, and a siamese network example using shared weights and the contrastive loss.
[example] update paths in net surgery
[fix] snapshot model weights as .caffemodel, solver state as .solverstate
set up datum size for WindowDataLayer
Merge pull request #1091 from ronghanghu/fix_window_data_layer

set up datum size for WindowDataLayer
Merge pull request #1088 from shelhamer/fix-solverstate-filename

Fix snapshot filename for solver states
[Bugfix] Move error checking closer to file read

Previously, if (height > 0 && width > 0) was true, the
cv::resize() function would be called before cv_img_origin was
confirmed valid; if the image file/filename was not valid, this
caused an opencv assert error like this:

terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/A3p0_4200_32550/batserve/A3p0/glnxa64/OpenCV/modules/imgproc/src/imgwarp.cpp:1725: error: (-215)
  ssize.area() > 0 in function resize
Merge pull request #1093 from CellScope/io-cant-load-error-msg

[fix] Move file reading error checking closer to actual file read command
Display averaged loss over the last several iterations
Update readme.md files of cifar10 and mnist examples. Fixed broken links.
Updated mnist/readme.md file with additional information.
test convolution against explicit reference implementation

To thoroughly check convolution, the output is compared against a
reference implementation by explicit looping. Simple and group
convolution by the Caffe and cuDNN engines are checked against the
reference.
test convolution by random weights for robustness
[docs] comment ConvolutionLayer
[docs] lenet grooming
Merge pull request #1100 from cNikolaou/issue1099

Polish mnist + cifar10 examples.
Merge pull request #1104 from shelhamer/conv-comments-tests

Document and Test Convolution
use Blob directly instead of shared_ptr for EltwiseLayer::max_idx_

This is in keeping with #742.
add abstract Layer::Reshape, and document the new method protocol