Tensorflow.js tf.layers.bidirectional() 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.bidirectional function is a bidirectional wrapper for RNNs layer.
tf.layers.bidirectional( args )
Parameters: This function accepts objects as parameters with the following fields:
- layers: It is the instance of RNN layer which is to be wrapped.
- mergeMode: It should be ‘sum’ or ‘mul’ or ‘concat’ or ‘ave’. It is the mode at which the output of forward and backward or RNNs are combined.
- inputShape:It should be an array of numbers. This field is used to create the input layer which is used to be inserted before this layer.
- batchInputShape: It should be an array of numbers. This field will be used if the input shape and this field are provided as a parameter for creating the input layer which is used to insert before this layer.
- batchSize: It should be a number. In the absence of batchInputShape, this field is used to create batchInputShape with input shape. batchInputShape : [ batchSize , …inputShape].
- dtype: If this layer is used as the input layer, then this field is used as the data type for this layer.
- name: It should be a string type. this field defines the name for this layer.
- trainable: It should be boolean. This field defines whether the weights of this layer are trainable with fit or not.
- weights: This should be a tensor that defines the initial weight value for this layer.
Returns: It returns Bidirectional.
Tensor [[-0.6737164, -1.6011676, 1.9193256], [-1.3474327, -3.2023351, 3.8386512], [-2.0211492, -4.8035026, 5.7579765], [-2.6948655, -6.4046702, 7.6773024]]