Tensorflow.js tf.Sequential Class
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
Tensorflow.js tf.Sequential class is a model of the collection of layers in stack form. These layers are connected to the respective neighbor layer. We use tf.Sequential() function to create tf.Sequential class instance. The tf.Sequential class has many methods which are used to apply in instances.
Parameters: This method accepts the following parameter:
- args: It depends on the method. Different methods accept different parameters.
Return Value: Different method returns different return value tf.Tensor object, etc.
Example 1: In this example, we will see add() method which is used to add a layer at top of the layer. It takes layer as a parameter and returns void.
Tensor [[0.5581576, 0.3110509], [0.546664 , 0.3369413], [0.5634928, 0.2920811], [0.5309308, 0.3545613]]
Example 2: In this example, we will see the summary() method which is used to print a summary of layer instance. It takes line length which is the custom length of the summary, and positions which is the width of the summary column, and at last print function which is used to customize the output of the summary. It returns void.
_________________________________________________________________ Layer (type) Output shape Param # ================================================================= dense_Dense34 (Dense) [null,6] 18 _________________________________________________________________ dense_Dense35 (Dense) [null,3] 21 _________________________________________________________________ dense_Dense36 (Dense) [null,2] 8 ================================================================= Total params: 47 Trainable params: 47 Non-trainable params: 0 _________________________________________________________________
Please Login to comment...