Tensorflow.js tf.layers.conv1d() Function
Parameters: This function accepts following parameters:
- args: This is object type that contains following values:
- filters: It is the number that defined the dimension of the output tensor. It the number of filters in the convolution.
- kernelSize: It define the convolution window to the convolution layers which means subset of input data takes at once.
- strides: It define the unit to move in input data by the convolution layer in each dimensions.
- padding: It define the padding to the convolution layer which means to amount to data added to the input data during processing. It’ s value can be ‘valid’ , ‘same’, and ‘causal’.
- dataFormat: It define the data format of the input data as data is in ‘channelsFirst’ or in ‘channelsLast’.
- dilationRate: It is used to dilate the convolution in each dimension. It is used to define the space in between the values in kernel.
- activation: It define the activation function to use in for the input data.
- useBias: It is used for making decision for using bias vector or not.
- kernelInitializer: It is the initial weight for the kernel in convolution layer. It define the way to set the initial random weights of convolution layers.
- biasInitializer: It is the initial weight for the bias vector of convolution layer.
- kernelConstraint: It is the constraint for the convolution layer kernel weight which is used to increase the efficiency.
- biasConstraint: It is the constraint for the convolution layer bias vector to increase the efficiency.
- kernelRegularizer: It is the regularizer function that is applied to matrix of the weight of the kernel to regularize it.
- biasRegularizer: It the regularizer function that is applied to the bias vector to regularize it.
- activityRegularizer: it is the function that is applied to the activation for regularize purpose.
- inputShape: It declared that this layer accepts the input layer of this shape. it is only used for the input layer.
- batchInputShape: It define the batch size of input layer. It is used for the input layer.
- batchSize: It is used as supplementary to the batchInputShape in process of making input layer.
- dtype: It define the data-type for this layer. ‘float32’ is the default value for layer.
- trainable: It is used to make layer trainable of function or not.
- weights: It is the initial weight value of this layer.
- inputDtype: It is used deciding the data-type of the input layer.
Example 1: In this example, we will create sequential model and add the 1d convolution layer to it with filter ,kernelSize ,inputShape and activation. At last we compile our model with layers and see the summary of it.
_________________________________________________________________ Layer (type) Output shape Param # ================================================================= input1 (InputLayer) [null,7,4] 0 _________________________________________________________________ conv1d_Conv1D1 (Conv1D) [null,1,10] 290 _________________________________________________________________ dense_Dense1 (Dense) [null,1,7] 77 ================================================================= Total params: 367 Trainable params: 367 Non-trainable params: 0 _________________________________________________________________
Example 2: In this example, we will see how the convolution layer filter the input data as per the configuration. Here we make convolution layer with the inputShape ,filter , kernelSize ,activation and compile the model with it. With the convolution layer filtered we use predict function for the input data.
Input layer shape : ,3,4 Convolution layer shape : ,2,2 Tensor [[[0.5468831, 0.4990641], [0.3059803, 0.4743758]], [[0.4450175, 0.4848864], [0.3678558, 0.4276305]], [[0.4802476, 0.5687023], [0.4083693, 0.4854257]]]
Please Login to comment...