In implementation of happy model, I think, I implemented step by step as commented suggestions all the layers according to the documentation given by the links carefully. But I get this error “The added layer must be an instance of class Layer”. I tried google search and “stackoverflow”, still I can’t figure it out. please anyone can give me a suggestion what can I do now…??
That message means that one of the entries in the big list of sequential layers that you built is not a subclass of a TF Keras Layer. There could be lots of ways for that to happen: using a different TF function than the ones that they listed is one, but it sounds like you have checked carefully. The other would be that you have accidentally “invoked” one of the functions with an input value, which converts the entry into a tensor (the return value of the function) instead of the layer function itself.
The syntax is a little confusing, but the TF Layer functions are actually functions that return other functions, right? That’s the crucial point here. You call the layer function in order to define it with the appropriate parameters (eg number of filters for a conv layer or pad size for a padding layer or …). Just as an example, here’s how you call the ZeroPadding layer function to define a pad layer that pads by 1:
The value of that expression is the actual function that you could then call like this and pass it an input tensor:
The value of that expression is the output tensor equal to Z2 with the new padding. There are two separate sets of parens there because there are two levels of function invocation happening.
In the happyModel case, we only want to do the first layer of function invocation for each of the layers in the “sequential” list that we are building. So we also need a comma after each layer, unless you are using the “add()” method of the Sequentlal class to build your happyModel.
actually in your expression when I define z2 outside the function as per documentation, it gives error. But when I define it as input_shape in function, it run successfully…
Thank You So Much.
Thank you for your support…