Search code examples
jsonexportkeraskeras-layer

Keras JSON export: inbound_nodes


I am trying to understand and how to interprate the JSON representation of a keras model. Each layer has it's inputs saved within the field inbound_nodes. What I don't understand are they arrays.

For example for 2 Inputs for a merge layer it looks like that:

inbound_nodes: [
  [
    ['average_pooling2d_1', 0, 0, {}],
    ['conv2d_3', 0, 0, {}],
  ]
]

Whats up with all the arrays? Why not save like that:

inbound_nodes: ['average_pooling2d_1', 'conv2d_3']

I guess the structure is because sometimes additional information must be saved somehow. What kind of information is that? E.g. when is the size of inbound_nodes > 1?


Solution

  • The parameters behind 'pooling2d' may be designed for future features.The size of inbound_nodes>1 when layers have other data stream.For more details,check the definition of Node and Layer keras source code