tf.eye
Создать единичную матрицу или набор матриц.
tf.eye(
num_rows,
num_columns=None,
batch_shape=None,
dtype=tf.dtypes.float32,
name=None
)
Используется в блокнотах
| Используется в руководстве | Используется в учебниках |
|---|---|
См. также tf.ones, tf.zeros, tf.fill, tf.one_hot.
# Construct one identity matrix.
tf.eye(2)
==> [[1., 0.],
[0., 1.]]
# Construct a batch of 3 identity matrices, each 2 x 2.
# batch_identity[i, :, :] is a 2 x 2 identity matrix, i = 0, 1, 2.
batch_identity = tf.eye(2, batch_shape=[3])
# Construct one 2 x 3 "identity" matrix
tf.eye(2, num_columns=3)
==> [[ 1., 0., 0.],
[ 0., 1., 0.]]
| Аргументы | |
|---|---|
num_rows | Неотрицательное скалярное значение int32 Tensor, определяющее число строк в каждой матрице набора. |
num_columns | Необязательное неотрицательное скалярное значение int32 Tensor, определяющее число столбцов в каждой матрице набора. По умолчанию num_rows. |
batch_shape | Список или кортеж Python-целых чисел или одномерный int32 Tensor. При указании этого параметра, возвращаемая Tensor будет иметь ведущие размерности набора в этом формате. |
dtype | Тип элемента в результирующей Tensor |
name | Имя этого Op. По умолчанию "eye". |
| Возвращаемое значение | |
|---|---|
Tensor формы batch_shape + [num_rows, num_columns] |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/eye