TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks.
- tf.ones: This methods accepts the shape and type and returns a tensor of give shape and type having all values set to 1.
- tf.fill: This method accepts shape, value and type and returns a tensor of given shape and type having all values set to value.
Example 1: This example uses ones() method to create a tensor with all elements set to one.
Res: tf.Tensor( [[1. 1. 1.] [1. 1. 1.]], shape=(2, 3), dtype=float32)
Example 2: This example uses fill() method with value = 1 to create a tensor with all elements set to one.
Res: tf.Tensor( [[1 1 1] [1 1 1]], shape=(2, 3), dtype=int32)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- TensorFlow - How to create a tensor of all ones that has the same shape as the input tensor
- TensorFlow - How to create one hot tensor
- TensorFlow - How to create a numpy ndarray from a tensor
- TensorFlow - How to stack a list of rank-R tensors into one rank-(R+1) tensor in parallel
- Introduction to Tensor with Tensorflow
- TensorFlow - How to add padding to a tensor
- TensorFlow - How to create a TensorProto
- One Hot Encoding using Tensorflow
- wxPython - Create Radio Button using Create() function
- wxPython - Create Static Box using Create() method
- Create and display a one-dimensional array-like object using Pandas in Python
- Python program to check if a string has at least one letter and one number
- Create an n x n square matrix, where all the sub-matrix have the sum of opposite corner elements as even
- Python | Classify Handwritten Digits with Tensorflow
- Introduction to TensorFlow
- Python | Tensorflow cos() method
- Linear Regression Using Tensorflow
- Python | Tensorflow nn.sigmoid()
- Python | Tensorflow nn.relu() and nn.leaky_relu()
- Python | Tensorflow nn.softplus()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.