# Sequential API and Functional API

**URL:** <https://dlai.staged-by-discourse.com/t/sequential-api-and-functional-api/477929>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [October 26, 2023, 1:57pm UTC](https://dlai.staged-by-discourse.com/t/sequential-api-and-functional-api/477929 "2023-10-26T13:57:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jingni\_Huang](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jingni\_Huang](https://dlai.staged-by-discourse.com/u/Jingni_Huang)\
**Post date:** [October 26, 2023, 1:57pm UTC](https://dlai.staged-by-discourse.com/t/sequential-api-and-functional-api/477929/1 "2023-10-26T13:57:07Z")

</div>

Week 1, second assignment again:

In the text just mentioned the difference between sequential and functional API is one is one input with one out, the latter is multiple input with multiple output.

Now i already see that the output from sequential is with Y\_test\_shape(150, 1) and functional is (120,6). Am I right?

But why there is multiple input of sequential which is X\_train\_shape(600,64, 64, 3), why here is not single input? what is it different with functional input (1080, 64, 64, 3)? Only batch size different?

---

<div class="post-metadata">

**Author:** ![li400100](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@li400100](https://dlai.staged-by-discourse.com/u/li400100)\
**Post date:** [October 26, 2023, 2:22pm UTC](https://dlai.staged-by-discourse.com/t/sequential-api-and-functional-api/477929/2 "2023-10-26T14:22:58Z")

</div>

Hi Jingni,

Not sure if I understand your question clearly, one input and one output means one input tensor and one output tensor, (600,64, 64, 3) or (1080, 64, 64, 3) is one tensor though it has multiple dimensions.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlaistaging/user_avatar/dlai.staged-by-discourse.com/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://dlai.staged-by-discourse.com/u/paulinpaloalto)\
**Post date:** [October 26, 2023, 3:24pm UTC](https://dlai.staged-by-discourse.com/t/sequential-api-and-functional-api/477929/3 "2023-10-26T15:24:57Z")

</div>

[Here’s a thread](http://dlai.staged-by-discourse.com/t/tips-for-troubles-with-sequential-and-functional-api-syntax/52202) that gives a much more complete introduction to the Sequential and Functional APIs than we get in the notebook. Definitely worth reading through that and I hope it will make things a lot clearer.

---

<div class="post-metadata">

**Author:** ![ai\_curious](https://sea1.discourse-cdn.com/dlaistaging/user_avatar/dlai.staged-by-discourse.com/ai_curious/32/128003_2.png) [@ai\_curious](https://dlai.staged-by-discourse.com/u/ai_curious)\
**Post date:** [October 26, 2023, 4:00pm UTC](https://dlai.staged-by-discourse.com/t/sequential-api-and-functional-api/477929/4 "2023-10-26T16:00:09Z")

</div>

> [@Jingni\_Huang](#):
>
> the difference between sequential and functional API is one is one input with one out, the latter is multiple input with multiple output.

A nuance is that the Sequential API supports _only_ a single input object and single output object. Whereas the Functional API supports multiple input objects and output objects _but doesn’t require them_. That is, you can use either the Sequential or Functional API to define a model with single input and output. If you need multiple, then Functional is your only choice.

Also, note that while the Sequential API limits you to a single input _object_, that doesn’t imply a single input _value_ as in a scalar. In fact, the input object is a [Keras InputLayer](https://www.tensorflow.org/api_docs/python/tf/keras/layers/InputLayer) that can have a complex `input_shape`. So your input shape can be multidimensional, even when using the Sequential API. HTH
