We often use $\mathbf{X}$ to denote the feature tensor of the samples. The values in a tensor object is not mutable. The following table shows some conventional ways to structure different feature [1]. In this note, we specifically focus on $2$-dimensional tensor for simplicity.
Conventional Structure of Features
tf.eye(dim) API
Create an identity matrix
> tf.eye(4)
<tf.Tensor: shape=(4, 4), dtype=float32, numpy=
array([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]], dtype=float32)>
tf.ones(shape) API
Create a tensor full of ones with the given shape
> tf.ones((4, 5))
<tf.Tensor: shape=(4, 5), dtype=float32, numpy=
array([[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.]], dtype=float32)>
tf.zeros(shape) API
Create a tensor full of zeros with the given shape
> tf.zeros((4, 5))
<tf.Tensor: shape=(4, 5), dtype=float32, numpy=
array([[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.]], dtype=float32)>
tf.ones_like(tensor) API
Create a tensor full of ones with same shape as the given tensor