tensorflow--math--3--矩阵数学函数--tf.eye

函数别名:

tf.eye
tf.linalg.eye

函数参数

tf.eye(
    num_rows,
    num_columns=None,
    batch_shape=None,
    dtype=tf.float32,
    name=None
)

函数所在脚本位置

tensorflow/python/ops/linalg_ops.py.

See the guide: Math > Matrix Math Functions

建立 identity matrix, or a batch of matrices.

例子

#Construct one identity matrix.

tf.eye(2)
==> [[1., 0.],
     [0., 1.]]

#Construct a batch of 3 identity matricies, 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])

#建立 2 x 3 “identity” matrix

tf.eye(2, num_columns=3)
==> [[ 1.,  0.,  0.],
     [ 0.,  1.,  0.]]

参数说明:

num_rows: Non-negative int32 scalar Tensor giving the number of rows in each batch matrix.
num_columns: Optional non-negative int32 scalar Tensor giving the number of columns in each batch matrix. Defaults to num_rows.
batch_shape: A list or tuple of Python integers or a 1-D int32 Tensor. If provided, the returned Tensor will have leading batch dimensions of this shape.
dtype: The type of an element in the resulting Tensor
name: A name for this Op. Defaults to "eye".
Returns:
A Tensor of shape batch_shape + [num_rows, num_columns]

参考资料

https://www.tensorflow.org/api_docs/python/tf/eye

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn