Beispiel #1
0
    def test_sSE_2d_shape(self):
        input_shape = (2, 16, 16, 32)
        x = tf.ones(input_shape)
        se_layer = SpatialSELayer()
        out_se = se_layer(x)

        with self.cached_session() as sess:
            sess.run(tf.global_variables_initializer())
            out = sess.run(out_se)
            x_shape = tuple(x.shape.as_list())
            self.assertAllClose(x_shape, out.shape)
Beispiel #2
0
    def test_sSE_2d_excitation_op(self):
        input_shape = (2, 16, 16, 32)
        x = tf.random_uniform(input_shape,seed=0)
        se_layer = SpatialSELayer()
        out_se = se_layer(x)

        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            x=sess.run(x)
            x_0_0=float(x[0,0,0,0])
            x_0_1=float(x[0,0,0,1])

        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            out = sess.run(out_se)
            out_0_0=float(out[0,0,0,0])
            out_0_1=float(out[0,0,0,1])

        div_0_0=out_0_0/x_0_0
        div_0_1=out_0_1/x_0_1

        with self.cached_session() as sess:
            self.assertAlmostEqual(div_0_0, div_0_1,places=5)