2

In keras say you have

layer1

and

layer2

You want to add these two layers, and you have to use Add from keras.layers.merge and you can't use the functional api.

Add doesn't take any inputs, so I don't see how it can possibly help in setting up the graph. I'm using keras 2.06.

lars
  • 1,976
  • 5
  • 33
  • 47
  • 2
    Why can't you use the functional API? – Dr. Snoopy Jul 23 '17 at 21:52
  • From Chollet's upcoming book: "These three important use cases --multi-input models, multi-output models, and graph-like models-- are not possible when using only the Sequential model class in Keras. But there is also a different, far more general and flexible way to use Keras: the functional API. " – MattMcKnight Jul 23 '17 at 23:02

1 Answers1

2

If you take the sum of two layers like that, your network graph would look like this

   |        |
layer1    layer2
    \      /
     \    /
      \  /
       \/
      sum

Such a layer is by definition not sequential (since sum takes more than one input), so performing this using the Sequential API is impossible. You must use the Functional API.

Jonas Adler
  • 10,365
  • 5
  • 46
  • 73