From c80f6f585549334022996395015cd490cc2644c8 Mon Sep 17 00:00:00 2001 From: Jonathan L Long Date: Thu, 23 Jul 2015 20:41:40 -0700 Subject: [PATCH] [pytest] simple test of top-less layers --- python/caffe/test/test_net_spec.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/caffe/test/test_net_spec.py b/python/caffe/test/test_net_spec.py index 65b73b9..b344946 100644 --- a/python/caffe/test/test_net_spec.py +++ b/python/caffe/test/test_net_spec.py @@ -41,6 +41,14 @@ def anon_lenet(batch_size): loss = L.SoftmaxWithLoss(ip2, label) return loss.to_proto() +def silent_net(): + n = caffe.NetSpec() + n.data, n.data2 = L.DummyData(shape=[dict(dim=[3]), dict(dim=[4, 2])], + ntop=2) + n.silence_data = L.Silence(n.data, ntop=0) + n.silence_data2 = L.Silence(n.data2, ntop=0) + return n.to_proto() + class TestNetSpec(unittest.TestCase): def load_net(self, net_proto): f = tempfile.NamedTemporaryFile(delete=False) @@ -65,3 +73,10 @@ class TestNetSpec(unittest.TestCase): net_proto.layer[6].top) net = self.load_net(net_proto) self.assertEqual(len(net.layers), 9) + + def test_zero_tops(self): + """Test net construction for top-less layers.""" + + net_proto = silent_net() + net = self.load_net(net_proto) + self.assertEqual(len(net.forward()), 0) -- 2.7.4