How it works...

The function begins with extracting the shape of the given input layer. As stated in previous recipes, the shape of the input layer comprises four integers: image number, image height, image width, and the number of color channels in the image. The number of features (num_features) is then evaluated using a dot-product of image height, image weight, and number of color channels.

Then, the layer is flattened or reshaped into a two-dimensional tensor (using tf$reshape). The first dimension is set to -1 (which is equal to the total number of images) and the second dimension is the number of features.

Finally, the function returns a list of flattened layers along with the total number of (input) features.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset