>>> import tensorflow as tf
>>> a = tf.linalg.band_part(tf.ones((5,5)),-1,0)
>>> print(a)
Tensor("MatrixBandPart:0", shape=(5, 5), dtype=float32)
>>> sess = tf.Session()
2021-12-29 10:18:26.173019: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX512F
2021-12-29 10:18:26.183988: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2494140000 Hz
2021-12-29 10:18:26.188170: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4c81610 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-12-29 10:18:26.188205: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
>>> sess.run(a)
array([[1., 0., 0., 0., 0.],
[1., 1., 0., 0., 0.],
[1., 1., 1., 0., 0.],
[1., 1., 1., 1., 0.],
[1., 1., 1., 1., 1.]], dtype=float32)
>>> b = 1 -a
>>> sess.run(b)
array([[0., 1., 1., 1., 1.],
[0., 0., 1., 1., 1.],
[0., 0., 0., 1., 1.],
[0., 0., 0., 0., 1.],
[0., 0., 0., 0., 0.]], dtype=float32)
01-27
2740
