Python - tensorflow.fill() Last Updated : 10 Jul, 2020 Comments Improve Suggest changes Like Article Like Report TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. fill() is used to generate a tensor having scalar value. Syntax: tensorflow.fill( dims, value, name) Parameters: dims: It is 1-D sequence of dtype int32 or int64 with non-negative integers representing the shape of the resulting Tensor.value: It is the value to be filled.name(optional): It defines the name of the operation. Returns: It returns a Tensor of shape dim. Raises: InvalidArgumentError: This error is raised when dim contains negative values.NotFoundError: This error is raised when dim contains non-integer values. Example 1: Python3 # Importing the library import tensorflow as tf # Initializing the input dim = [4, 5] value = 5 # Printing the input print('dim: ', dim) print('value: ', value) # Calculating result res = tf.fill(dim, value) # Printing the result print('res: ', res) Output: dim: [4, 5] value: 5 res: tf.Tensor( [[5 5 5 5 5] [5 5 5 5 5] [5 5 5 5 5] [5 5 5 5 5]], shape=(4, 5), dtype=int32) Example 2: Python3 # Importing the library import tensorflow as tf # Initializing the input dim = [4, 2, 5] value = 5 # Printing the input print('dim: ', dim) print('value: ', value) # Calculating result res = tf.fill(dim, value) # Printing the result print('res: ', res) Output: dim: [4, 2, 5] value: 5 res: tf.Tensor( [[[5 5 5 5 5] [5 5 5 5 5]] [[5 5 5 5 5] [5 5 5 5 5]] [[5 5 5 5 5] [5 5 5 5 5]] [[5 5 5 5 5] [5 5 5 5 5]]], shape=(4, 2, 5), dtype=int32) Comment More infoAdvertise with us Next Article Python - tensorflow.fill() aman neekhara Follow Improve Article Tags : Python Tensorflow Python-Tensorflow Practice Tags : python Similar Reads Python - tensorflow.eye() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. tensorflow.eye() is used to generate identity matrix. Syntax: tensorflow.eye( num_rows, num_columns, batch_shape, dtype, name) Parameters: num_rows: It is int32 scalar 2 min read Python - tensorflow.identity() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. identity() returns a Tensor with the same shape and contents as input. Syntax: tensorflow.identity(input, name) Parameters: input: It is a Tensor.name(optional): It def 2 min read Python - tensorflow.gather() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. gather() is used to slice the input tensor based on the indices provided. Syntax: tensorflow.gather( params, indices, validate_indices, axis, batch_dims, name) Paramete 2 min read Tensorflow - linspace() in Python TensorFlow is an open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. While working with TensorFlow many times we need to generate evenly-spaced values in an interval. tensorflow.linspace(): This method takes starting tensor, ending tens 2 min read Python - tensorflow.concat() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. concat() is used to concatenate tensors along one dimension. Syntax: tensorflow.concat( values, axis, name ) Parameter: values: It is a tensor or list of tensor.axis: It 2 min read Like