Skip to content

Instantly share code, notes, and snippets.

@Pythonista7
Last active September 29, 2021 14:19
Show Gist options
  • Save Pythonista7/2848f2101b7b1581d3700fd0d3e06fa7 to your computer and use it in GitHub Desktop.
Save Pythonista7/2848f2101b7b1581d3700fd0d3e06fa7 to your computer and use it in GitHub Desktop.
rank_0_tensor = tf.constant(4)
print(rank_0_tensor)
tf.Tensor(4, shape=(), dtype=int32)
rank_1_tensor = tf.constant([2.0, 3.0, 4.0])
print(rank_1_tensor)
rank_2_tensor = tf.constant([[1, 2],
[3, 4],
[5, 6]], dtype=tf.float16)
print(rank_2_tensor)
tf.Tensor(
[[1. 2.]
[3. 4.]
[5. 6.]], shape=(3, 2), dtype=float16)
rank_4_tensor = tf.zeros([3, 2, 4, 5])
<tf.Tensor: shape=(3, 2, 4, 5), dtype=float32,
numpy= array( ... ), dtype=float32)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment