Tensorflow.js tf.buffer() 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.buffer() function is used to create an empty Tensor Buffer for the specified data type and shape. The values are set in the created buffer using buffer.set() function.
tf.buffer (shape, dtype, values)
Parameters: This function accepts three parameters which are illustrated below:
- shape: An array of integers which defines the shape of output tensor.
- dtype: The data type of the created buffer. It’s defaults value is ‘float32’. This parameter is optional.
- values: The values for the created buffer. It’s default values is zeros. This parameter is optional.
Return Value: This function does not return any values as it create the buffer only.
Tensor [[0, 0], [0, 0]]
Tensor [[0 , 15, 0 ], [0 , 0 , 20], [10, 0 , 0 ]]