Course 4 week 2 alpaca model how to pass the augmentation to the preprocessing

In my implementation of the alpaca model the augmentation part does not seem to get inserted into the model .
In alpaca_summary the second layer of the type ‘sequential’ is missing.
What arguments do the functions ‘data_augmentation’ and ‘preprocess_input’ require to work together or how do I need to apply them?

They are both functions which take an input tensor and produce an output tensor. The data augmentation step comes first and then the output of that is the input to the preprocessing step. Note that the data augmentation function is passed as a function reference, so you just use the name of the parameter, not the name of the actual function being passed in as the argument.

The template code has lots of comments and other guidance. Please take another look with what I said above in mind and see if things make more sense now …

Thanks for your reply! It was helpful and I could get the code running.
I guess what got me stuck is that in its function definition the data_augmenter does not take any argument and returns an object of type tf.keras.Sequential. Therefore I had a problem to understand why it is used with a tensor as input and a tensor as output.
I think I will try to find some documentation that gets me a better understanding on how tensorflow and keras work (do you have a recommendation?).
Thanks again!

The point is that a Keras “Sequential” object is a function that takes a tensor as input and produces a tensor as output. It happens to also include internally a bunch of “layers” which are also functions that have the same property. In other words, data_augmenter is a function which returns a function as its output (return value). Then you take that value (the function) and invoke it with specified inputs and outputs. Notice that in the function definition of alpaca_model, they include this:

data_augmentation = data_augmenter()

So that invokes the function data_augmenter and makes the variable data_augmentation a reference to the function that was returned. Of course, it also makes data_augmentation a “named parameter” which is thus optional at call time and has the default value assigned by the above assignment statement.

Here’s the TF documentation for Keras Sequential. It is a subclass of “Model”.