Mastering TensorFlow 1.x
上QQ阅读APP看书,第一时间看更新

Functional API for creating the Keras model

In the functional API, you create the model as an instance of the Model class that takes an input and output parameter. The input and output parameters represent one or more input and output tensors, respectively.

As an example, use the following code to instantiate a model from the functional API:

model = Model(inputs=tensor1, outputs=tensor2)

In the above code, tensor1 and tensor2 are either tensors or objects that can be treated like tensors, for example, Keras layer objects.

If there are more than one input and output tensors, they can be passed as a list, as shown in the following example:

model = Model(inputs=[i1,i2,i3], outputs=[o1,o2,o3])