Make CheckGradientExhaustive fail for topless layers

Without this commit, it is possible to mistakenly call CheckGradientExhaustive on a layer with no top blobs (i.e., a loss layer), causing the gradient check to silently succeed while doing nothing. With this commit, doing so will cause the test to fail.

All existing tests continue to pass.

See, e.g., @aravindhm's comment in #258.