Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of data Type Information and Transformation in TensorFlow

Shulou Source: shulou.com Published: 2022-06-02 16:12:14 09月21日 Update

This article mainly introduces the TensorFlow data type information and conversion example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

I. data type

In tf, data types are integer (default is int32), floating point (default is float32), and Boolean, string.

II. Data type information ① .device

To see where tensor is (on CPU or GPU), you can convert it through .cpu (), .gpu (). If the data is in a different processor location, it cannot be calculated.

② .numpy ()

Convert the data to numpy format.

③ .shape / .ndim

View shapes, .ndim view dimensions, and .is_tensor check to see if they are tensor types.

3. Data type conversion ① tf.convert_to_tensor

When converting data to tensor, it defaults to int64 when converting from Numpy to tensor. You need to specify a type before it becomes the default type of tf, that is, int32.

② tf.cast ()

The data type conversion of tensor can be realized.

Note: in in-depth learning, you need to find the gradient of the parameters, you need to variable packaging, you will have the trainable attribute, so you can find the gradient. If you write the propagation process yourself, the updated parameters also need to be packaged with variable.

Thank you for reading this article carefully. I hope the article "sample Analysis of data Type Information and conversion in TensorFlow" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Types data articles information examples analysis parameters gradients wrappers learning that is values locations interests can be passed at the same time processors characters strings attributes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker Xiaomi Microsoft MySQL