Add label pair functionality to contrastive loss function

This PR adds functionality to the contrastive loss function.

Now, in addition to being able to pass a 1/0 label that specifies similar or dissimilar pairs, you can pass in two labels, and similarity will be calculated on the fly.

I do this by keeping another buffer, `similar_`, which is computed at feed-forward time.

This is useful, for example, if you want to combine a contrastive loss function with a soft-max loss, or if you want to use the same data loaders for both siamese or N-way classification networks.

The way I'm doing it does add a slight bit of additional overhead, but I think it's negligible.

If you hook up only one label, the 1/0 behavior still happens.

I also added a check to make sure there are either 3 or 4 bottom blobs.
To be cross platform, [boost::filesystem::create_directories](http://www.boost.org/doc/libs/1_56_0/libs/filesystem/doc/reference.html#create_directories) is a better option.