BVLC/caffe — pull request #479 by jeffdonahue (2014-06-08 19:53:40+00:00)
Title: Layers declare their types and number of bottom/top blobs

This PR attempts to unify/standardize all the "___ Layer takes N blobs as input." messages at the top of each layer's SetUp method throughout the code. Adds 6 methods: `ExactNumBottomBlobs`, `MinBottomBlobs`, `MaxBottomBlobs`, and the analogs for `Top`, which should be overridden by layers requiring a specific min/max/exact number of bottom/top blobs (which currently is all of them, as far as I know).

The design I settled on was to actually perform these checks in an additional method, `CheckBlobCounts`, which `Net::Init` now calls right before `SetUp`. The drawback is that now any `SetUp` call is not protected by a blob count check. I also considered just changing the `SetUp` method to be implemented only in the `Layer` superclass and just have that method call `CheckBlobCounts` and `FurtherSetUp`, which would be the method that subclasses now override (as in the current `NeuronLayer` and `LossLayer`s) -- do people think this would be a better design? (Or some other design entirely? Definitely open to suggestions.)