<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes</li>
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04):  Ubuntu 16.04</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A</li>
<li>TensorFlow installed from (source or binary): pip</li>
<li>TensorFlow version (use command below):  1.14.0rc0</li>
<li>Python version: 3.6.8</li>
<li>Bazel version (if compiling from source): N/A</li>
<li>GCC/Compiler version (if compiling from source): N/A</li>
<li>CUDA/cuDNN version: N/A</li>
<li>GPU model and memory: N/A</li>
</ul>
<p dir="auto"><strong>Describe the current behavior</strong></p>
<p dir="auto">I am encountering serialization issues when trying to dump the <code class="notranslate">config</code> from a <code class="notranslate">tf.keras.Model</code> object without complex things like custom layers (or even Lambdas...)</p>
<p dir="auto">The code worked well with tf 1.13.1 however in tf 1.1.4, json/yaml serialization fails, and <code class="notranslate">to_yaml</code> and <code class="notranslate">model_from_yaml</code> fails as well</p>
<p dir="auto"><strong>Describe the expected behavior</strong></p>
<p dir="auto">We should be able to serialize the config from a <code class="notranslate">tf.keras.Model</code> into json/yaml and load it back, especially without using custom layers</p>
<p dir="auto">I checked the changelog for 1.14 and did not see any documented changes on model serialization for tf 1.14</p>
<p dir="auto">Is serializing just the config file something that should not be done in 1.14 / 2.0 ?</p>
<p dir="auto"><strong>Code to reproduce the issue</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# %%
import tensorflow as tf
import json
from ruamel import yaml


# %%
def mini_cnn(input_shape, num_classes):
    inputs = tf.keras.layers.Input(shape=input_shape)

    x = tf.keras.layers.Conv2D(16, (3, 3), padding=&quot;same&quot;, use_bias=False)(inputs)
    x = tf.keras.layers.BatchNormalization(axis=-1)(x)
    x = tf.keras.layers.Activation(&quot;relu&quot;)(x)
    x = tf.keras.layers.MaxPooling2D((2, 2), strides=2)(x)
    x = tf.keras.layers.Conv2D(32, (3, 3), padding=&quot;same&quot;, use_bias=False)(x)
    x = tf.keras.layers.BatchNormalization(axis=-1)(x)
    x = tf.keras.layers.Activation(&quot;relu&quot;)(x)
    x = tf.keras.layers.MaxPooling2D((2, 2), strides=2)(x)
    x = tf.keras.layers.Conv2D(64, (3, 3), padding=&quot;same&quot;, use_bias=False)(x)
    x = tf.keras.layers.BatchNormalization(axis=-1)(x)
    x = tf.keras.layers.Activation(&quot;relu&quot;)(x)
    x = tf.keras.layers.MaxPooling2D((2, 2), strides=2)(x)
    x = tf.keras.layers.Flatten()(x)
    x = tf.keras.layers.Dense(64, use_bias=False)(x)
    x = tf.keras.layers.BatchNormalization(axis=-1)(x)
    x = tf.keras.layers.Activation(&quot;relu&quot;)(x)
    x = tf.keras.layers.Dropout(0.25)(x)

    logits = tf.keras.layers.Dense(num_classes, use_bias=True, name=&quot;logits&quot;)(x)
    probas = tf.keras.layers.Activation(activation=&quot;softmax&quot;, name=&quot;probas&quot;)(logits)

    model = tf.keras.Model(inputs=inputs, outputs=probas, name=&quot;model&quot;)

    return model


# %%
m = mini_cnn((64, 64, 3), 2)

## %%
try:
    c = m.get_config()
    m2 = tf.keras.models.model_from_config(c)
except:
    print(&quot;c error&quot;)

try:
    y = m.to_yaml()
    m2 = tf.keras.models.model_from_yaml(y)
except:
    print(&quot;y error&quot;)

try:
    j = m.to_json()
    m2 = tf.keras.models.model_from_json(j)
except:
    print(&quot;j error&quot;)"><pre class="notranslate"><span class="pl-c"># %%</span>
<span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span>
<span class="pl-k">import</span> <span class="pl-s1">json</span>
<span class="pl-k">from</span> <span class="pl-s1">ruamel</span> <span class="pl-k">import</span> <span class="pl-s1">yaml</span>


<span class="pl-c"># %%</span>
<span class="pl-k">def</span> <span class="pl-en">mini_cnn</span>(<span class="pl-s1">input_shape</span>, <span class="pl-s1">num_classes</span>):
    <span class="pl-s1">inputs</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Input</span>(<span class="pl-s1">shape</span><span class="pl-c1">=</span><span class="pl-s1">input_shape</span>)

    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Conv2D</span>(<span class="pl-c1">16</span>, (<span class="pl-c1">3</span>, <span class="pl-c1">3</span>), <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">"same"</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)(<span class="pl-s1">inputs</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>(<span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">1</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Activation</span>(<span class="pl-s">"relu"</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">MaxPooling2D</span>((<span class="pl-c1">2</span>, <span class="pl-c1">2</span>), <span class="pl-s1">strides</span><span class="pl-c1">=</span><span class="pl-c1">2</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Conv2D</span>(<span class="pl-c1">32</span>, (<span class="pl-c1">3</span>, <span class="pl-c1">3</span>), <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">"same"</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>(<span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">1</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Activation</span>(<span class="pl-s">"relu"</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">MaxPooling2D</span>((<span class="pl-c1">2</span>, <span class="pl-c1">2</span>), <span class="pl-s1">strides</span><span class="pl-c1">=</span><span class="pl-c1">2</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Conv2D</span>(<span class="pl-c1">64</span>, (<span class="pl-c1">3</span>, <span class="pl-c1">3</span>), <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">"same"</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>(<span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">1</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Activation</span>(<span class="pl-s">"relu"</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">MaxPooling2D</span>((<span class="pl-c1">2</span>, <span class="pl-c1">2</span>), <span class="pl-s1">strides</span><span class="pl-c1">=</span><span class="pl-c1">2</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Flatten</span>()(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Dense</span>(<span class="pl-c1">64</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>(<span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">1</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Activation</span>(<span class="pl-s">"relu"</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Dropout</span>(<span class="pl-c1">0.25</span>)(<span class="pl-s1">x</span>)

    <span class="pl-s1">logits</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Dense</span>(<span class="pl-s1">num_classes</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"logits"</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">probas</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Activation</span>(<span class="pl-s1">activation</span><span class="pl-c1">=</span><span class="pl-s">"softmax"</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"probas"</span>)(<span class="pl-s1">logits</span>)

    <span class="pl-s1">model</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-v">Model</span>(<span class="pl-s1">inputs</span><span class="pl-c1">=</span><span class="pl-s1">inputs</span>, <span class="pl-s1">outputs</span><span class="pl-c1">=</span><span class="pl-s1">probas</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"model"</span>)

    <span class="pl-k">return</span> <span class="pl-s1">model</span>


<span class="pl-c"># %%</span>
<span class="pl-s1">m</span> <span class="pl-c1">=</span> <span class="pl-en">mini_cnn</span>((<span class="pl-c1">64</span>, <span class="pl-c1">64</span>, <span class="pl-c1">3</span>), <span class="pl-c1">2</span>)

<span class="pl-c">## %%</span>
<span class="pl-k">try</span>:
    <span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s1">m</span>.<span class="pl-en">get_config</span>()
    <span class="pl-s1">m2</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">models</span>.<span class="pl-en">model_from_config</span>(<span class="pl-s1">c</span>)
<span class="pl-k">except</span>:
    <span class="pl-en">print</span>(<span class="pl-s">"c error"</span>)

<span class="pl-k">try</span>:
    <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">m</span>.<span class="pl-en">to_yaml</span>()
    <span class="pl-s1">m2</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">models</span>.<span class="pl-en">model_from_yaml</span>(<span class="pl-s1">y</span>)
<span class="pl-k">except</span>:
    <span class="pl-en">print</span>(<span class="pl-s">"y error"</span>)

<span class="pl-k">try</span>:
    <span class="pl-s1">j</span> <span class="pl-c1">=</span> <span class="pl-s1">m</span>.<span class="pl-en">to_json</span>()
    <span class="pl-s1">m2</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">models</span>.<span class="pl-en">model_from_json</span>(<span class="pl-s1">j</span>)
<span class="pl-k">except</span>:
    <span class="pl-en">print</span>(<span class="pl-s">"j error"</span>)</pre></div>
<p dir="auto"><strong>Other info / logs</strong></p>
<p dir="auto">YAML traceback (seems to come from batchnorm)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;run.py&quot;, line 49, in &lt;module&gt;
    m2 = tf.keras.models.model_from_yaml(y)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/saving/model_config.py&quot;, line 78, in model_from_yaml
    return deserialize(config, custom_objects=custom_objects)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py&quot;, line 89, in deserialize
    printable_module_name='layer')
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py&quot;, line 192, in deserialize_keras_object
    list(custom_objects.items())))
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py&quot;, line 1131, in from_config
    process_node(layer, node_data)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py&quot;, line 1087, in process_node
    layer(flat_input_tensors[0], **kwargs)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py&quot;, line 591, in __call__
    self._maybe_build(inputs)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py&quot;, line 1881, in _maybe_build
    self.build(input_shapes)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/layers/normalization.py&quot;, line 286, in build
    raise ValueError('Duplicate axis: %s' % self.axis)
ValueError: Duplicate axis: ListWrapper([3, 3])
None"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "run.py", line 49, in &lt;module&gt;
    m2 = tf.keras.models.model_from_yaml(y)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/saving/model_config.py", line 78, in model_from_yaml
    return deserialize(config, custom_objects=custom_objects)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 89, in deserialize
    printable_module_name='layer')
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 192, in deserialize_keras_object
    list(custom_objects.items())))
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 1131, in from_config
    process_node(layer, node_data)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 1087, in process_node
    layer(flat_input_tensors[0], **kwargs)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 591, in __call__
    self._maybe_build(inputs)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1881, in _maybe_build
    self.build(input_shapes)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/layers/normalization.py", line 286, in build
    raise ValueError('Duplicate axis: %s' % self.axis)
ValueError: Duplicate axis: ListWrapper([3, 3])
None
</code></pre></div>
<p dir="auto">config error</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;run.py&quot;, line 42, in &lt;module&gt;
    m2 = tf.keras.models.model_from_config(c)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/saving/model_config.py&quot;, line 55, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File &quot;/my-env/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py&quot;, line 81, in deserialize
    layer_class_name = config['class_name']
KeyError: 'class_name'
None
"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "run.py", line 42, in &lt;module&gt;
    m2 = tf.keras.models.model_from_config(c)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/saving/model_config.py", line 55, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/my-env/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 81, in deserialize
    layer_class_name = config['class_name']
KeyError: 'class_name'
None

</code></pre></div>
<p dir="auto">here is the yaml file that was generated:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="backend: tensorflow
class_name: Model
config:
  input_layers:
  - [input_1, 0, 0]
  layers:
  - class_name: InputLayer
    config:
      batch_input_shape: !!python/tuple [null, 64, 64, 3]
      dtype: float32
      name: input_1
      sparse: false
    inbound_nodes: []
    name: input_1
  - class_name: Conv2D
    config:
      activation: linear
      activity_regularizer: null
      bias_constraint: null
      bias_initializer:
        class_name: Zeros
        config: {dtype: float32}
      bias_regularizer: null
      data_format: channels_last
      dilation_rate: &amp;id001 !!python/tuple [1, 1]
      dtype: float32
      filters: 16
      kernel_constraint: null
      kernel_initializer:
        class_name: GlorotUniform
        config: {dtype: float32, seed: null}
      kernel_regularizer: null
      kernel_size: !!python/tuple [3, 3]
      name: conv2d
      padding: same
      strides: &amp;id002 !!python/tuple [1, 1]
      trainable: true
      use_bias: false
    inbound_nodes:
    - - - input_1
        - 0
        - 0
        - {}
    name: conv2d
  - class_name: BatchNormalization
    config:
      axis: !!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper
        listitems: [3]
        state:
          _external_modification: false
          _last_wrapped_list_snapshot: [3]
          _non_append_mutation: false
          _self_extra_variables: []
          _self_trainable: true
          _storage: [3]
      beta_constraint: null
      beta_initializer:
        class_name: Zeros
        config: {dtype: float32}
      beta_regularizer: null
      center: true
      dtype: float32
      epsilon: 0.001
      gamma_constraint: null
      gamma_initializer:
        class_name: Ones
        config: {dtype: float32}
      gamma_regularizer: null
      momentum: 0.99
      moving_mean_initializer:
        class_name: Zeros
        config: {dtype: float32}
      moving_variance_initializer:
        class_name: Ones
        config: {dtype: float32}
      name: batch_normalization
      scale: true
      trainable: true
    inbound_nodes:
    - - - conv2d
        - 0
        - 0
        - {}
    name: batch_normalization
  - class_name: Activation
    config: {activation: relu, dtype: float32, name: activation, trainable: true}
    inbound_nodes:
    - - - batch_normalization
        - 0
        - 0
        - {}
    name: activation
  - class_name: MaxPooling2D
    config:
      data_format: channels_last
      dtype: float32
      name: max_pooling2d
      padding: valid
      pool_size: !!python/tuple [2, 2]
      strides: !!python/tuple [2, 2]
      trainable: true
    inbound_nodes:
    - - - activation
        - 0
        - 0
        - {}
    name: max_pooling2d
  - class_name: Conv2D
    config:
      activation: linear
      activity_regularizer: null
      bias_constraint: null
      bias_initializer:
        class_name: Zeros
        config: {dtype: float32}
      bias_regularizer: null
      data_format: channels_last
      dilation_rate: *id001
      dtype: float32
      filters: 32
      kernel_constraint: null
      kernel_initializer:
        class_name: GlorotUniform
        config: {dtype: float32, seed: null}
      kernel_regularizer: null
      kernel_size: !!python/tuple [3, 3]
      name: conv2d_1
      padding: same
      strides: *id002
      trainable: true
      use_bias: false
    inbound_nodes:
    - - - max_pooling2d
        - 0
        - 0
        - {}
    name: conv2d_1
  - class_name: BatchNormalization
    config:
      axis: !!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper
        listitems: [3]
        state:
          _external_modification: false
          _last_wrapped_list_snapshot: [3]
          _non_append_mutation: false
          _self_extra_variables: []
          _self_trainable: true
          _storage: [3]
      beta_constraint: null
      beta_initializer:
        class_name: Zeros
        config: {dtype: float32}
      beta_regularizer: null
      center: true
      dtype: float32
      epsilon: 0.001
      gamma_constraint: null
      gamma_initializer:
        class_name: Ones
        config: {dtype: float32}
      gamma_regularizer: null
      momentum: 0.99
      moving_mean_initializer:
        class_name: Zeros
        config: {dtype: float32}
      moving_variance_initializer:
        class_name: Ones
        config: {dtype: float32}
      name: batch_normalization_1
      scale: true
      trainable: true
    inbound_nodes:
    - - - conv2d_1
        - 0
        - 0
        - {}
    name: batch_normalization_1
  - class_name: Activation
    config: {activation: relu, dtype: float32, name: activation_1, trainable: true}
    inbound_nodes:
    - - - batch_normalization_1
        - 0
        - 0
        - {}
    name: activation_1
  - class_name: MaxPooling2D
    config:
      data_format: channels_last
      dtype: float32
      name: max_pooling2d_1
      padding: valid
      pool_size: !!python/tuple [2, 2]
      strides: !!python/tuple [2, 2]
      trainable: true
    inbound_nodes:
    - - - activation_1
        - 0
        - 0
        - {}
    name: max_pooling2d_1
  - class_name: Conv2D
    config:
      activation: linear
      activity_regularizer: null
      bias_constraint: null
      bias_initializer:
        class_name: Zeros
        config: {dtype: float32}
      bias_regularizer: null
      data_format: channels_last
      dilation_rate: *id001
      dtype: float32
      filters: 64
      kernel_constraint: null
      kernel_initializer:
        class_name: GlorotUniform
        config: {dtype: float32, seed: null}
      kernel_regularizer: null
      kernel_size: !!python/tuple [3, 3]
      name: conv2d_2
      padding: same
      strides: *id002
      trainable: true
      use_bias: false
    inbound_nodes:
    - - - max_pooling2d_1
        - 0
        - 0
        - {}
    name: conv2d_2
  - class_name: BatchNormalization
    config:
      axis: !!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper
        listitems: [3]
        state:
          _external_modification: false
          _last_wrapped_list_snapshot: [3]
          _non_append_mutation: false
          _self_extra_variables: []
          _self_trainable: true
          _storage: [3]
      beta_constraint: null
      beta_initializer:
        class_name: Zeros
        config: {dtype: float32}
      beta_regularizer: null
      center: true
      dtype: float32
      epsilon: 0.001
      gamma_constraint: null
      gamma_initializer:
        class_name: Ones
        config: {dtype: float32}
      gamma_regularizer: null
      momentum: 0.99
      moving_mean_initializer:
        class_name: Zeros
        config: {dtype: float32}
      moving_variance_initializer:
        class_name: Ones
        config: {dtype: float32}
      name: batch_normalization_2
      scale: true
      trainable: true
    inbound_nodes:
    - - - conv2d_2
        - 0
        - 0
        - {}
    name: batch_normalization_2
  - class_name: Activation
    config: {activation: relu, dtype: float32, name: activation_2, trainable: true}
    inbound_nodes:
    - - - batch_normalization_2
        - 0
        - 0
        - {}
    name: activation_2
  - class_name: MaxPooling2D
    config:
      data_format: channels_last
      dtype: float32
      name: max_pooling2d_2
      padding: valid
      pool_size: !!python/tuple [2, 2]
      strides: !!python/tuple [2, 2]
      trainable: true
    inbound_nodes:
    - - - activation_2
        - 0
        - 0
        - {}
    name: max_pooling2d_2
  - class_name: Flatten
    config: {data_format: channels_last, dtype: float32, name: flatten, trainable: true}
    inbound_nodes:
    - - - max_pooling2d_2
        - 0
        - 0
        - {}
    name: flatten
  - class_name: Dense
    config:
      activation: linear
      activity_regularizer: null
      bias_constraint: null
      bias_initializer:
        class_name: Zeros
        config: {dtype: float32}
      bias_regularizer: null
      dtype: float32
      kernel_constraint: null
      kernel_initializer:
        class_name: GlorotUniform
        config: {dtype: float32, seed: null}
      kernel_regularizer: null
      name: dense
      trainable: true
      units: 64
      use_bias: false
    inbound_nodes:
    - - - flatten
        - 0
        - 0
        - {}
    name: dense
  - class_name: BatchNormalization
    config:
      axis: !!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper
        listitems: [1]
        state:
          _external_modification: false
          _last_wrapped_list_snapshot: [1]
          _non_append_mutation: false
          _self_extra_variables: []
          _self_trainable: true
          _storage: [1]
      beta_constraint: null
      beta_initializer:
        class_name: Zeros
        config: {dtype: float32}
      beta_regularizer: null
      center: true
      dtype: float32
      epsilon: 0.001
      gamma_constraint: null
      gamma_initializer:
        class_name: Ones
        config: {dtype: float32}
      gamma_regularizer: null
      momentum: 0.99
      moving_mean_initializer:
        class_name: Zeros
        config: {dtype: float32}
      moving_variance_initializer:
        class_name: Ones
        config: {dtype: float32}
      name: batch_normalization_3
      scale: true
      trainable: true
    inbound_nodes:
    - - - dense
        - 0
        - 0
        - {}
    name: batch_normalization_3
  - class_name: Activation
    config: {activation: relu, dtype: float32, name: activation_3, trainable: true}
    inbound_nodes:
    - - - batch_normalization_3
        - 0
        - 0
        - {}
    name: activation_3
  - class_name: Dropout
    config: {dtype: float32, name: dropout, noise_shape: null, rate: 0.25, seed: null,
      trainable: true}
    inbound_nodes:
    - - - activation_3
        - 0
        - 0
        - {}
    name: dropout
  - class_name: Dense
    config:
      activation: linear
      activity_regularizer: null
      bias_constraint: null
      bias_initializer:
        class_name: Zeros
        config: {dtype: float32}
      bias_regularizer: null
      dtype: float32
      kernel_constraint: null
      kernel_initializer:
        class_name: GlorotUniform
        config: {dtype: float32, seed: null}
      kernel_regularizer: null
      name: logits
      trainable: true
      units: 2
      use_bias: true
    inbound_nodes:
    - - - dropout
        - 0
        - 0
        - {}
    name: logits
  - class_name: Activation
    config: {activation: softmax, dtype: float32, name: probas, trainable: true}
    inbound_nodes:
    - - - logits
        - 0
        - 0
        - {}
    name: probas
  name: model
  output_layers:
  - [probas, 0, 0]
keras_version: 2.2.4-tf"><pre class="notranslate"><span class="pl-ent">backend</span>: <span class="pl-s">tensorflow</span>
<span class="pl-ent">class_name</span>: <span class="pl-s">Model</span>
<span class="pl-ent">config</span>:
  <span class="pl-ent">input_layers</span>:
  - <span class="pl-s">[input_1, 0, 0]</span>
  <span class="pl-ent">layers</span>:
  - <span class="pl-ent">class_name</span>: <span class="pl-s">InputLayer</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">batch_input_shape</span>: <span class="pl-s">!!python/tuple [null, 64, 64, 3]</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">name</span>: <span class="pl-s">input_1</span>
      <span class="pl-ent">sparse</span>: <span class="pl-c1">false</span>
    <span class="pl-ent">inbound_nodes</span>: <span class="pl-s">[]</span>
    <span class="pl-ent">name</span>: <span class="pl-s">input_1</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Conv2D</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">activation</span>: <span class="pl-s">linear</span>
      <span class="pl-ent">activity_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">bias_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">data_format</span>: <span class="pl-s">channels_last</span>
      <span class="pl-ent">dilation_rate</span>: <span class="pl-s">&amp;id001 !!python/tuple [1, 1]</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">filters</span>: <span class="pl-c1">16</span>
      <span class="pl-ent">kernel_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">GlorotUniform</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32, seed: null}</span>
      <span class="pl-ent">kernel_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_size</span>: <span class="pl-s">!!python/tuple [3, 3]</span>
      <span class="pl-ent">name</span>: <span class="pl-s">conv2d</span>
      <span class="pl-ent">padding</span>: <span class="pl-s">same</span>
      <span class="pl-ent">strides</span>: <span class="pl-s">&amp;id002 !!python/tuple [1, 1]</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">use_bias</span>: <span class="pl-c1">false</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - input_1</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">conv2d</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">BatchNormalization</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">axis</span>: <span class="pl-s">!!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper</span>
        <span class="pl-ent">listitems</span>: <span class="pl-s">[3]</span>
        <span class="pl-ent">state</span>:
          <span class="pl-ent">_external_modification</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_last_wrapped_list_snapshot</span>: <span class="pl-s">[3]</span>
          <span class="pl-ent">_non_append_mutation</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_self_extra_variables</span>: <span class="pl-s">[]</span>
          <span class="pl-ent">_self_trainable</span>: <span class="pl-c1">true</span>
          <span class="pl-ent">_storage</span>: <span class="pl-s">[3]</span>
      <span class="pl-ent">beta_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">beta_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">beta_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">center</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">epsilon</span>: <span class="pl-c1">0.001</span>
      <span class="pl-ent">gamma_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">gamma_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">gamma_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">momentum</span>: <span class="pl-c1">0.99</span>
      <span class="pl-ent">moving_mean_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">moving_variance_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization</span>
      <span class="pl-ent">scale</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - conv2d</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Activation</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{activation: relu, dtype: float32, name: activation, trainable: true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - batch_normalization</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">activation</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">MaxPooling2D</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">data_format</span>: <span class="pl-s">channels_last</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">name</span>: <span class="pl-s">max_pooling2d</span>
      <span class="pl-ent">padding</span>: <span class="pl-s">valid</span>
      <span class="pl-ent">pool_size</span>: <span class="pl-s">!!python/tuple [2, 2]</span>
      <span class="pl-ent">strides</span>: <span class="pl-s">!!python/tuple [2, 2]</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - activation</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">max_pooling2d</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Conv2D</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">activation</span>: <span class="pl-s">linear</span>
      <span class="pl-ent">activity_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">bias_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">data_format</span>: <span class="pl-s">channels_last</span>
      <span class="pl-ent">dilation_rate</span>: <span class="pl-s">*id001</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">filters</span>: <span class="pl-c1">32</span>
      <span class="pl-ent">kernel_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">GlorotUniform</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32, seed: null}</span>
      <span class="pl-ent">kernel_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_size</span>: <span class="pl-s">!!python/tuple [3, 3]</span>
      <span class="pl-ent">name</span>: <span class="pl-s">conv2d_1</span>
      <span class="pl-ent">padding</span>: <span class="pl-s">same</span>
      <span class="pl-ent">strides</span>: <span class="pl-s">*id002</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">use_bias</span>: <span class="pl-c1">false</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - max_pooling2d</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">conv2d_1</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">BatchNormalization</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">axis</span>: <span class="pl-s">!!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper</span>
        <span class="pl-ent">listitems</span>: <span class="pl-s">[3]</span>
        <span class="pl-ent">state</span>:
          <span class="pl-ent">_external_modification</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_last_wrapped_list_snapshot</span>: <span class="pl-s">[3]</span>
          <span class="pl-ent">_non_append_mutation</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_self_extra_variables</span>: <span class="pl-s">[]</span>
          <span class="pl-ent">_self_trainable</span>: <span class="pl-c1">true</span>
          <span class="pl-ent">_storage</span>: <span class="pl-s">[3]</span>
      <span class="pl-ent">beta_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">beta_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">beta_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">center</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">epsilon</span>: <span class="pl-c1">0.001</span>
      <span class="pl-ent">gamma_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">gamma_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">gamma_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">momentum</span>: <span class="pl-c1">0.99</span>
      <span class="pl-ent">moving_mean_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">moving_variance_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization_1</span>
      <span class="pl-ent">scale</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - conv2d_1</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization_1</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Activation</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{activation: relu, dtype: float32, name: activation_1, trainable: true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - batch_normalization_1</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">activation_1</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">MaxPooling2D</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">data_format</span>: <span class="pl-s">channels_last</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">name</span>: <span class="pl-s">max_pooling2d_1</span>
      <span class="pl-ent">padding</span>: <span class="pl-s">valid</span>
      <span class="pl-ent">pool_size</span>: <span class="pl-s">!!python/tuple [2, 2]</span>
      <span class="pl-ent">strides</span>: <span class="pl-s">!!python/tuple [2, 2]</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - activation_1</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">max_pooling2d_1</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Conv2D</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">activation</span>: <span class="pl-s">linear</span>
      <span class="pl-ent">activity_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">bias_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">data_format</span>: <span class="pl-s">channels_last</span>
      <span class="pl-ent">dilation_rate</span>: <span class="pl-s">*id001</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">filters</span>: <span class="pl-c1">64</span>
      <span class="pl-ent">kernel_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">GlorotUniform</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32, seed: null}</span>
      <span class="pl-ent">kernel_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_size</span>: <span class="pl-s">!!python/tuple [3, 3]</span>
      <span class="pl-ent">name</span>: <span class="pl-s">conv2d_2</span>
      <span class="pl-ent">padding</span>: <span class="pl-s">same</span>
      <span class="pl-ent">strides</span>: <span class="pl-s">*id002</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">use_bias</span>: <span class="pl-c1">false</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - max_pooling2d_1</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">conv2d_2</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">BatchNormalization</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">axis</span>: <span class="pl-s">!!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper</span>
        <span class="pl-ent">listitems</span>: <span class="pl-s">[3]</span>
        <span class="pl-ent">state</span>:
          <span class="pl-ent">_external_modification</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_last_wrapped_list_snapshot</span>: <span class="pl-s">[3]</span>
          <span class="pl-ent">_non_append_mutation</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_self_extra_variables</span>: <span class="pl-s">[]</span>
          <span class="pl-ent">_self_trainable</span>: <span class="pl-c1">true</span>
          <span class="pl-ent">_storage</span>: <span class="pl-s">[3]</span>
      <span class="pl-ent">beta_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">beta_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">beta_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">center</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">epsilon</span>: <span class="pl-c1">0.001</span>
      <span class="pl-ent">gamma_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">gamma_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">gamma_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">momentum</span>: <span class="pl-c1">0.99</span>
      <span class="pl-ent">moving_mean_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">moving_variance_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization_2</span>
      <span class="pl-ent">scale</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - conv2d_2</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization_2</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Activation</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{activation: relu, dtype: float32, name: activation_2, trainable: true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - batch_normalization_2</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">activation_2</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">MaxPooling2D</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">data_format</span>: <span class="pl-s">channels_last</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">name</span>: <span class="pl-s">max_pooling2d_2</span>
      <span class="pl-ent">padding</span>: <span class="pl-s">valid</span>
      <span class="pl-ent">pool_size</span>: <span class="pl-s">!!python/tuple [2, 2]</span>
      <span class="pl-ent">strides</span>: <span class="pl-s">!!python/tuple [2, 2]</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - activation_2</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">max_pooling2d_2</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Flatten</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{data_format: channels_last, dtype: float32, name: flatten, trainable: true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - max_pooling2d_2</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">flatten</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Dense</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">activation</span>: <span class="pl-s">linear</span>
      <span class="pl-ent">activity_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">bias_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">kernel_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">GlorotUniform</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32, seed: null}</span>
      <span class="pl-ent">kernel_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">name</span>: <span class="pl-s">dense</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">units</span>: <span class="pl-c1">64</span>
      <span class="pl-ent">use_bias</span>: <span class="pl-c1">false</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - flatten</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">dense</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">BatchNormalization</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">axis</span>: <span class="pl-s">!!python/object/new:tensorflow.python.training.tracking.data_structures._ListWrapper</span>
        <span class="pl-ent">listitems</span>: <span class="pl-s">[1]</span>
        <span class="pl-ent">state</span>:
          <span class="pl-ent">_external_modification</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_last_wrapped_list_snapshot</span>: <span class="pl-s">[1]</span>
          <span class="pl-ent">_non_append_mutation</span>: <span class="pl-c1">false</span>
          <span class="pl-ent">_self_extra_variables</span>: <span class="pl-s">[]</span>
          <span class="pl-ent">_self_trainable</span>: <span class="pl-c1">true</span>
          <span class="pl-ent">_storage</span>: <span class="pl-s">[1]</span>
      <span class="pl-ent">beta_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">beta_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">beta_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">center</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">epsilon</span>: <span class="pl-c1">0.001</span>
      <span class="pl-ent">gamma_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">gamma_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">gamma_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">momentum</span>: <span class="pl-c1">0.99</span>
      <span class="pl-ent">moving_mean_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">moving_variance_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Ones</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization_3</span>
      <span class="pl-ent">scale</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - dense</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">batch_normalization_3</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Activation</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{activation: relu, dtype: float32, name: activation_3, trainable: true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - batch_normalization_3</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">activation_3</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Dropout</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32, name: dropout, noise_shape: null, rate: 0.25, seed: null,</span>
      <span class="pl-ent">trainable</span>: <span class="pl-s">true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - activation_3</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">dropout</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Dense</span>
    <span class="pl-ent">config</span>:
      <span class="pl-ent">activation</span>: <span class="pl-s">linear</span>
      <span class="pl-ent">activity_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">bias_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">Zeros</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32}</span>
      <span class="pl-ent">bias_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">dtype</span>: <span class="pl-s">float32</span>
      <span class="pl-ent">kernel_constraint</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">kernel_initializer</span>:
        <span class="pl-ent">class_name</span>: <span class="pl-s">GlorotUniform</span>
        <span class="pl-ent">config</span>: <span class="pl-s">{dtype: float32, seed: null}</span>
      <span class="pl-ent">kernel_regularizer</span>: <span class="pl-c1">null</span>
      <span class="pl-ent">name</span>: <span class="pl-s">logits</span>
      <span class="pl-ent">trainable</span>: <span class="pl-c1">true</span>
      <span class="pl-ent">units</span>: <span class="pl-c1">2</span>
      <span class="pl-ent">use_bias</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - dropout</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">logits</span>
  - <span class="pl-ent">class_name</span>: <span class="pl-s">Activation</span>
    <span class="pl-ent">config</span>: <span class="pl-s">{activation: softmax, dtype: float32, name: probas, trainable: true}</span>
    <span class="pl-ent">inbound_nodes</span>:
    - <span class="pl-s">- - logits</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-c1">0</span>
        - <span class="pl-s">{}</span>
    <span class="pl-ent">name</span>: <span class="pl-s">probas</span>
  <span class="pl-ent">name</span>: <span class="pl-s">model</span>
  <span class="pl-ent">output_layers</span>:
  - <span class="pl-s">[probas, 0, 0]</span>
<span class="pl-ent">keras_version</span>: <span class="pl-s">2.2.4-tf</span></pre></div>
<p dir="auto">One can see the error with ListWrapper</p>
<p dir="auto">Note:</p>
<p dir="auto">Lambda layers serialization seem to fail, whereas they worked in tf1.13 as well</p>
<p dir="auto">Currently, the caching that <a href="https://github.com/tensorflow/tensorflow/blob/7fa0cf39f854d5fdaaa19ad6425dfed02f5fea64/tensorflow/python/ops/distributions/bijector_impl.py#L114">Bijector</a> objects do to avoid unnecessary calculations does not work when the bijector is used in a <a href="https://github.com/tensorflow/tensorflow/blob/7fa0cf39f854d5fdaaa19ad6425dfed02f5fea64/tensorflow/python/ops/distributions/transformed_distribution.py#L124">TransformedDistribution</a> object. I believe the culprit is the reshaping that the distribution object does <a href="https://github.com/tensorflow/tensorflow/blob/7fa0cf39f854d5fdaaa19ad6425dfed02f5fea64/tensorflow/python/ops/distributions/distribution.py#L640">here</a>; when we call Bijector.inverse on the output, the Bijector object cannot tell that this is merely a reshaped version of what it calculated previously.</p>
<p dir="auto">My use case is to sample from a TransformedDistribution and then later calculate the log probability of that sample.</p>
<p dir="auto">This issue is particularly a problem when using a bijector whose inverse is numerically delicate (in my case, I'm chaining together softplus bijectors and my own custom affine bijector).</p>
<p dir="auto">I'm willing to work on a fix for this problem, but I'm not sure what the best way to do it is (adding caching to the TransformedDistribution code might work, but that seems like code duplication).</p>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>OS Platform and Distribution</strong>: Ubuntu 16.04</li>
<li><strong>TensorFlow installed from</strong>: Source</li>
<li><strong>TensorFlow version</strong>: v1.1.0-rc2-773-g7fa0cf3 (commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/tensorflow/tensorflow/commit/7fa0cf39f854d5fdaaa19ad6425dfed02f5fea64/hovercard" href="https://github.com/tensorflow/tensorflow/commit/7fa0cf39f854d5fdaaa19ad6425dfed02f5fea64"><tt>7fa0cf3</tt></a>)</li>
<li><strong>Bazel version</strong>: 0.4.5</li>
</ul>