In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares with you is about what the tensor data structure in Tensorflow is. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Program = data structure + algorithm.
TensorFlow program = tensor data structure + computational graph algorithm language
Tensor and computational graph are the core concepts of TensorFlow.
A tensor is a multidimensional array. The Tensor of TensorFlow is similar to the array of numpy.
From the perspective of behavioral characteristics, there are two types of tensors, constant constant and variable Variable.
The value of constant cannot be reassigned in the calculation graph, and the variable can be reassigned by using operators such as assign in the calculation graph.
One, constant tensor
The data type of the tensor basically corresponds to numpy.array.
Import numpy as np
Import tensorflow as tf
I = tf.constant (1) # tf.int32 type constant
L = tf.constant (1 tf.int64 dtype = tf.int64) # constant of type
F = tf.constant (1.23) # tf.float32 type constant
D = tf.constant (3.14 dtype = tf.double) # tf.double type constant
S = tf.constant ("hello world") # tf.string type constant
B = tf.constant (True) # tf.bool type constant
Print (tf.int64 = = np.int64)
Print (tf.bool = = np.bool)
Print (tf.double = = np.float64)
Print (tf.string = = np.unicode) # tf.string type and np.unicode type are not equivalent
Different types of data can be represented by tensors of different dimensions (rank).
The scalar is a 0-dimensional tensor, the vector is a 1-dimensional tensor and the matrix is a 2-dimensional tensor.
The color image has three rgb channels, which can be expressed as a 3D tensor.
Video also has a time dimension, which can be expressed as a 4-dimensional tensor.
It can be simply summed up as follows: there are several layers of parentheses, that is, how many dimensions of the tensor.
You can use tf.cast to change the data type of the tensor.
The tensor in tensorflow can be transformed into the tensor in numpy by numpy method.
You can use the shape method to view the size of the tensor.
Second, variable tensor
The parameters that need to be trained in the model are generally set as variable tensors.
The above is what the tensor data structure in Tensorflow is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.