Now, that said, we have this feature, our feature extractor.
So we have feature extractor right here.
And then this inherits from layer.
So you inherit from TensorFlow layer and then we have and you need method and followed by a call method.
So that's it.
Now let's use the right syntax.
Here is a class.
Here is a method init method.
There we go.
You could always check on our free cars on python programming in case you are not versed with all this
syntax.
So that's it.
We have had that.
And now, just like the way we did when we were creating this feature extractor, let's go back to our
feature extractor with a functional API actually here, you'll see.
Let's copy this out and then get back to our model subclasses.
So that's it here.
Let's just put this down here.
Then we have the super feature extractor.
There we go.
That init.
So that's it.
Now that we have defined this, we could go ahead and use this layers as the attribute for this feature
extractor layer.
So there we go.
We have this year we have our conf the self de self dot com one which is this conf to dx right here.
So we take all this off and just place it here.
And then from here we have the batch batch one which is this batch nom layer right here, take this
and then place it right here we have the max pull to DX, take that off.
We have self dot pull one.
There we go.
So that's it.
And then we just repeat this process so we could have the self that comes one come to rather so come
to and then we just take up this parameters.
Let's take this from here and uh, place it right here.
So here, instead of having this, we just get this, and then the batch normal Max puts would remain
the same.
So that's it for our init method.
We now go ahead to build our call method.
We have our call method here which takes this input x, and then here what it does is it permits us
call each and every layer we've defined here in this init method.
So here we have x equals self, so the value of x is going to change.
We're going to pass it to self dot, conf one and several conf one is going to take an x.
This looks similar to the functional API we have x equals self dot batch one.
There we go, batch one and then we have x equals self dot pool 1xx equals self dot com to x and then
self dot batch two.
And finally we have self dot pool two.
That's it.
So now from here we just return x.
Also note that we could pass in a parameter an argument like the training which can tell us whether
to use a given layer or not doing the training process.
Nonetheless, for now, all this is going to be used or in training.
So we have that.
Now let's take all this off.
We run that.
There we go.
That's run correctly.
Now we should be able to build our model.
So here we have this little net model which took the feature extractor model from here.
Let's just copy this.
And then but before copying that, we have to ensure that we create this here.
So we have future subclass.
So we have our feature subclass, which is this feature extractor built right here.
So yeah, we have feature extractor build.
So that is it.
Now you could always pass this parameters like the number of filters they cannot size via this.
So you could pass this here, you could specify filters and and the kernel.
Sighs.
So let's let's just do that.
So let's say filters, text, kernel size stripes and say pattern and activation.
So we could pass all this here so that when we get to this point, we just we don't need to specify
all this.
So we'll simply take this off or no need to specify all this anymore.
Now we have our activation, all that specified.
Okay, We could also include a pool size.
Let's include a pool size and all this right here.
So let's just say, yeah, we're going to have two times the strikes because we to specify the strikes
to be one.
So let's take this off here.
We're going to have two times a strikes and we've defined yeah, we have the pool size.
So let's take this off and take let's take this off rather like let's get back.
So we take this off and take this off.
So that is it.
We've defined all that and now we are ready to pass all those values.
So we just simply copy all those values and then in-year, we specify the number of filters.
So yeah, let's take eight, the kernel size, let's take three, the number of strikes we have one.
The pattern here is valid, valid activation value, pool size is two.
So that's it.
So we've defined all this.
Now, at this point, let's ensure that we have this times two.
So let's run this now again.
And then we have our feature extractor, but we get in this error.
Let's try to understand why and how to solve this error.
So there we go.
Scrolling.
We have this.
Now, the reason why we have this error is because of the order in which this comes to the Texas arguments.
So if you look at this, trying to get this to come up anyway, we just look at the documentation.
You see we have filters, kernel size strikes, pattern data format.
So you see we have the data format, select the dilation rate groups before the activation.
So it's important that we specify that this is filters, equal filters, and then we specify kernel
size.
Equal kernel size, if not is going to take this to be the data format.
So that's it strikes pattern, equal pattern and activation, equal activation.
So this should be fine.
Now we run that again, we have this error, but this time around for the second conf layer.
So let's, let's just redo what we had done here and take this off notice filter size times two.
So here we have filters, times two, we try to do same for the max pull through.
DD So yeah, we have pull size, equal pool size, that's it strikes, that's fine.
And then yeah, we have pool size, equal pool size.
Okay, So now everything should work fine.
We run that and there we go.
Everything works fine.
So now we've created our layer, our feature subclass layer.
We will now be able to use it in this model right here.
So let's copy that and then get back to this or paste this out here and now.
Here we have our feature subclass, Let's take all this off subclass and then we could comfortably run
this and we get in this error.
Now let's get back to check.
We see batch two.
There's an error level, batch two.
Now you see here we have this two, it should be two and this should be two.
So that's fine.
Let's run that again and everything works well.
So you see, it gives us that same output we expect to get with this feature extractor right here.
Then one last thing we could do is instead of doing this way, let's insert some code.
Instead of doing this way, we are going to create a model using this model subclass method.
So here we just copy this out.
So we copy that out.
And then in here instead of having layers.
So yeah, we not have a layer, we have an A model.
So instead of having a layer, we now have model and then we're going to do.
Find a feature extractor.
So our feature extractor now is going to be the feature extractor we've just defined here.
So let's go up and there we go.
So we just we're going to get this feature extractor right here.
And then what we do is we put it in your.
So let's take all this off.
We have all this off that's now our feature extractor.
So we've got got this feature extractor.
That's it.
And then once we get X, we're going to pass this through a feature extractor.
There we go.
Let's take all this off and we'll find.
Now we're done with the feature extraction.
We could get the other parts which make up the model like this.
Flatten the dance and the batch.
Norm.
So let's take this here.
There we go.
We are in this model, and let's just copy it.
Let's paste it out here.
So here we're going to have this also note that we're going to have feature or let's say low net.
This is all the net model.
Modify this.
Here we have little net model, the net model.
So that's fine.
Now we've gotten this, everything is understood.
We now check out this set of the flatten, equal flatten.
And then next we have self dot dance one equal.
Let's copy this out from here simply.
So we have this dense right here, which is our dense one.
There we go.
We have our dense and then we have self dot batch one, which is all batch normalization.
There we go.
Copy this and paste.
We move to dense two and batch two.
So here we have dense two.
We have batch two.
This is ten actually.
So we have that.
And then finally we have this dense layer.
So let's take this off.
We have the dense layer.
I'll put one activation sigmoid.
So that's it.
We call this dense three.
So that's fine.
Everything seems okay.
Let's take this off now.
And then there we go.
We get into our call method.
So yeah, we get into this call method and this call method will basically call all this different layers.
So after the feature extraction, notice how we've created this class and this class makes use of this
feature extractor, which was also created using the same models of class and method.
So there we go.
We're using this here and we actually using it here.
So that's it.
Now we just make this course so we have x equal self flatten and then we pass x x equal self.
The dense one person x x
x equals self dot batch one person.
And then finally we have this.
So there we go.
We now return X just as we did previously, and we have our model.
So here we have our Loonette, Loonette model, Loonette subclass model and we have this Loonette here,
Loonette model.
So let's take this off and there we go.
We've just built our model, which when we try to find a summary, so we try to do Loonette subclass
that summary, what do we obtain?
You see, we this model has not yet been built.
Build a model first by calling, build or by calling the model on a batch of data.
So we're going to call this model on a batch of data.
Yeah, we're going to have a little net subclass and then we have two zeros.
So you have the zeros and one, two, two, 4 to 2, four and three.
So let's run this and see what we get.
That's fine.
So yeah, we have our summary and then we are ready to compile this model.
Yeah, we have the net net subclass.
So we compile the net subclass and then we're going to fit the net subclass Loonette subclass.
So we fit that.
And everything shall work.
Fine.
Let's take this to just five epochs.
We can see that we're getting similar results when we compare this with what we have with the functional
API and the sequential API.
So we now move on to creating custom layers.