CNN- Week 1 Assignment 2 Sequential API


I am trying to work through the 2nd assignment for week1. Creating the sequential model. However I am really stuck and not sure how to proceed.

  1. There is no input given in the method -def happyModel(). How do I go about defining the layers?
  2. When I try using X_train as the input I am getting the following error -Screen Shot 2021-06-05 at 3.17.12 PM

Could someone help me out in figuring out these issues?

Yes, this is new territory and it takes some getting used to. The point of the Sequential API is that we first do everything we need to “declare” or define what the model is, but at that stage we are not really invoking a function. We are defining the function, but not invoking it, so we don’t need to specify the input. That happens later.

All the tf.keras.layers functions return the actual functions that we will invoke later. So when you say, e.g., tfl.MaxPool2d(pool_size = (2,2)), that just returns the function that you will later call with the actual input. So the declaration of HappyModel is just a list (separated by commas) of the functions that comprise the model we are building.

I hope that gives at least a little more direction on how to get started on this.

1 Like