November 2019
Intermediate to advanced
296 pages
7h 52m
English
A tensor is a data structure that holds metadata such as shapes, data types, and pointers for the underlying buffer. To construct a tensor, we need to provide some data as parameters. tf.tensor allows us to create the arbitrary shape of the tensor:
tf.tensor([1, 2, 3, 4], [2, 2]).print(); Tensor [[1, 2], [3, 4]]
The API recognizes the dimensions of the given JavaScript array, which allows us to specify the shape explicitly:
tf.tensor([[1, 2], [3, 4]]).print(); Tensor [[1, 2], [3, 4]]
There are also several rank-specific APIs that we can use to create tensors:
These APIs ...
Read now
Unlock full access