<jupyter_start><jupyter_text>Tensors  - Shape of a tensor are the number of elements in each dimension (ex. 2 rows, 3 columns -> TensorShape([2, 3]))  - Rank of a tensor is the number of dimensions of the tensor<jupyter_code>s1 = tf.Variable('It is done', tf.string)
s1.shape, tf.rank(s1)
x1 = tf.Variable(32, tf.int32)
x1.shape, tf.rank(x1)
x2 = tf.Variable([[1, 2, 3], [4, 5, 6]], tf.int32)
x2.shape, tf.rank(x2)<jupyter_output><empty_output><jupyter_text>Reshaping tensors<jupyter_code>tf.reshape(x2, [3, 2])
tf.reshape(x2, [6, -1])  # -1 implies "infer the number of elements in this dimension"
tf.reshape(x2, [-1, 6])<jupyter_output><empty_output><jupyter_text>Constant and Variable tensors  - You can point the constant tensor's name to another tensor  - You cannot change the constant tensor's values inside, thus    - it cannot be used during training  - A variable tensor's values can be updated, thus    - it can be used during training (default).    - You can also create a variable tensor to be untrainable (using trainable=False)<jupyter_code>c = tf.constant([[1, 8, 9]], tf.int32)
c = tf.constant([[1, 2, 3]], tf.int32)
c
d = tf.Variable([1, 8, 9], tf.int32)
d
d = 2 * d
d<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1356907894736842, 'fraction_numerical': 0.04194078947368421, 'mean_word_length': 4.660465116279069, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '503034', 'license': 'MIT', 'n_tokens_mistral': 472, 'n_tokens_neox': 439, 'n_words': 149, 'path': 'tf2_basics.ipynb', 'repo_name': 'samirgadkari/ds', 'size': '1216'}