Tensorflow.js tf.layers.spatialDropout1d() Function Last Updated : 25 Apr, 2022 Comments Improve Suggest changes Like Article Like Report Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. The tf.layers.spatialDropout1d() function is used to apply the spatial 1D version of the dropout operation on data. Syntax: tf.layers.spatialDropout1d(args) Input shape: Arbitrary. When utilizing this layer as the initial layer in a model, use the inputShape configuration. Output shape: The output has the same shape as the input. Parameters: It accepts the args object which can have the following properties: rate (number): A float value between 0 and 1. The fraction of input units to drop.seed (number): An integer that will be used as a random seed.inputShape: If this property is set, it will be utilized to construct an input layer that will be inserted before this layer. batchInputShape: If this property is set, an input layer will be created and inserted before this layer. batchSize: If batchInputShape isn't supplied and inputShape is, batchSize is utilized to build the batchInputShape.dtype: It is the kind of data type for this layer. float32 is the default value. This parameter applies exclusively to input layers.name: This is the layer's name and is of string type.trainable: If the weights of this layer may be changed by fit. True is the default value.weights: The layer's initial weight values. Returns: It returns an object (SpatialDropout1D). Example 1: JavaScript import * as tf from "@tensorflow/tfjs"; const model = tf.sequential({ layers: [tf.layers.dense({ units: 1, inputShape: [10, 2] })], }); model.add(tf.layers.spatialDropout1d({ rate: 0.25 })); model.compile( { optimizer: "sgd", loss: "meanAbsoluteError" }, ); const result = model.evaluate( tf.ones([8, 10, 2]), tf.ones([8, 10, 1]), { batchSize: 4, }); result.print(); Output: Tensor 1.1040260791778564 Example 2: JavaScript import * as tf from "@tensorflow/tfjs"; const model = tf.sequential({ layers: [tf.layers.dense({ units: 1, inputShape: [5, 5] })], }); model.add(tf.layers.spatialDropout1d({ rate: 0.5, seed: 146 })); model.compile({ optimizer: "adam", loss: "meanSquaredError" }); const result = model.evaluate( tf.ones([4, 5, 5]), tf.ones([4, 5, 1]), { batchSize: 2, }); result.print(); Output: Tensor 7.158995151519775 Reference: https://js.tensorflow.org/api/latest/#layers.spatialDropout1d Comment More infoAdvertise with us Next Article Tensorflow.js tf.layers.spatialDropout1d() Function A aayushmohansinha Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Tensorflow.js-Basic TensorFlow.js-layers +1 More Similar Reads Tensorflow.js tf.layers.prelu() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 2 min read Tensorflow.js tf.layers.separableConv2d() Function 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js. The tf. 4 min read Tensorflow.js tf.layers.reshape() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The tf.layers.reshape() function is used to Reshape an input to a certain shape. Syntax: tf.layers.reshape(args) 2 min read Tensorflow.js tf.layers.maxPooling1d() Function 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.layers.maxPooling1d() function is used for max pooling operation on temporal data. Syntax: tf.layers.maxPooling1d( ar 3 min read Tensorflow.js tf.layers.reLU() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 2 min read Tensorflow.js tf.layers.softmax() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 2 min read Tensorflow.js tf.layers.lstm() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. tf.layers.lstm() function is used for creating an RNN layer consisting of one LSTMCell and the apply method of LS 5 min read Tensorflow.js tf.layers.simpleRNN() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 4 min read Tensorflow.js tf.layers.maximum() Function 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or Node.js. The tf.lay 2 min read Tensorflow.js tf.layers.multiply() Function 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. The tf.layers.multiply() function is used to perform element-wise multiplication of an array of inputs. Syntax: tf.layers.multiply() P 2 min read Like