Add test for vis_utils.plot_model with show_layer_activations=True
@@ -105,6 +105,30 @@ class ModelToDotFormatTest(tf.test.TestCase, parameterized.TestCase):
except ImportError:
pass
+ def test_plot_model_cnn_with_activations(self):
+ model = keras.Sequential()
+ model.add(keras.layers.Conv2D(
+ filters=2,
+ kernel_size=2,
+ input_shape=(9, 9, 3),
+ activation='relu'))
+ model.add(keras.layers.Conv2D(
+ filters=4,
+ kernel_size=2,
+ strides=(2, 2),
+ activation='relu'))
+ model.add(keras.layers.Flatten(name='flat'))
+ model.add(keras.layers.Dense(5, name='head', activation='softmax'))
+ dot_img_file = 'model_5.png'
+ try:
+ vis_utils.plot_model(
+ model, to_file=dot_img_file, show_shapes=True,
+ show_dtype=True, show_layer_activations=True)
+ self.assertTrue(tf.io.gfile.exists(dot_img_file))
+ tf.io.gfile.remove(dot_img_file)
+ except ImportError:
+ pass
+
@parameterized.parameters(
{'layer_range': ['block1a_project_conv', 'block1a_activation']},
{'layer_range': ['block1a_activation', 'block1a_project_conv']},
