About Tensorflow Fundamental_1

In this norebook, we’re going to cover some of the most fundamental concepts using Tensorflow.

More specifically, we’re going to cover:

  • Introduction to tensors
  • Getting information from tensors
  • Manipulating tensors
  • Tensors & Numpy
  • Using @
  • Using GPUs with TF

Tensor

Import Tensorflow

1
2
import tensorflow as tf
print(tf.__version__)

Tensorflow 包含了一維,二維,三維,多維

scalaer
vector
matrix

1
2
3
4
5
6
7
8
9
10
11
## check the number of dimensions of a tensor (ndim stands for number of dimensions)

scalar.ndim

## Create a vector
vector = tf.constant([10, 10])
vector

## Create a matrix (has more than 1 dimension)
matrix = tf.constant([[10, 7], [7, 10]])
matrix
1
2
3
4
5
6
7
8
# Let's create a tensor
tensor = tf.constant([[[1, 2, 3],
[4, 5, 6]],
[[7, 8, 9],
[10, 11, 12]],
[[13, 14, 15],
[16, 17, 18]]])
tensor
© 2022 Tiffany's Blog All Rights Reserved. 本站访客数人次 本站总访问量
Theme by hiero