Skip to content

Commit 8cd8f7b

Browse files
authored
Update tf.math and tf.linalg op names in Customization basics tensors and operations tutorial
1 parent f1408b6 commit 8cd8f7b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

site/en/tutorials/customization/basics.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"source": [
107107
"## Tensors\n",
108108
"\n",
109-
"A Tensor is a multi-dimensional array. Similar to NumPy `ndarray` objects, `tf.Tensor` objects have a data type and a shape. Additionally, `tf.Tensor`s can reside in accelerator memory (like a GPU). TensorFlow offers a rich library of operations (for example, `tf.math.add`, `tf.matmul`, and `tf.linalg.inv`) that consume and produce `tf.Tensor`s. These operations automatically convert built-in Python types. For example:\n"
109+
"A Tensor is a multi-dimensional array. Similar to NumPy `ndarray` objects, `tf.Tensor` objects have a data type and a shape. Additionally, `tf.Tensor`s can reside in accelerator memory (like a GPU). TensorFlow offers a rich library of operations (for example, `tf.math.add`, `tf.linalg.matmul`, and `tf.linalg.inv`) that consume and produce `tf.Tensor`s. These operations automatically convert built-in Python types. For example:\n"
110110
]
111111
},
112112
{
@@ -118,13 +118,13 @@
118118
},
119119
"outputs": [],
120120
"source": [
121-
"print(tf.add(1, 2))\n",
122-
"print(tf.add([1, 2], [3, 4]))\n",
123-
"print(tf.square(5))\n",
124-
"print(tf.reduce_sum([1, 2, 3]))\n",
121+
"print(tf.math.add(1, 2))\n",
122+
"print(tf.math.add([1, 2], [3, 4]))\n",
123+
"print(tf.math.square(5))\n",
124+
"print(tf.math.reduce_sum([1, 2, 3]))\n",
125125
"\n",
126126
"# Operator overloading is also supported\n",
127-
"print(tf.square(2) + tf.square(3))"
127+
"print(tf.math.square(2) + tf.math.square(3))"
128128
]
129129
},
130130
{
@@ -144,7 +144,7 @@
144144
},
145145
"outputs": [],
146146
"source": [
147-
"x = tf.matmul([[1]], [[2, 3]])\n",
147+
"x = tf.linalg.matmul([[1]], [[2, 3]])\n",
148148
"print(x)\n",
149149
"print(x.shape)\n",
150150
"print(x.dtype)"
@@ -191,11 +191,11 @@
191191
"ndarray = np.ones([3, 3])\n",
192192
"\n",
193193
"print(\"TensorFlow operations convert numpy arrays to Tensors automatically\")\n",
194-
"tensor = tf.multiply(ndarray, 42)\n",
194+
"tensor = tf.math.multiply(ndarray, 42)\n",
195195
"print(tensor)\n",
196196
"\n",
197197
"\n",
198-
"print(\"And NumPy operations convert Tensors to numpy arrays automatically\")\n",
198+
"print(\"And NumPy operations convert Tensors to NumPy arrays automatically\")\n",
199199
"print(np.add(tensor, 1))\n",
200200
"\n",
201201
"print(\"The .numpy() method explicitly converts a Tensor to a numpy array\")\n",
@@ -268,7 +268,7 @@
268268
"def time_matmul(x):\n",
269269
" start = time.time()\n",
270270
" for loop in range(10):\n",
271-
" tf.matmul(x, x)\n",
271+
" tf.linalg.matmul(x, x)\n",
272272
"\n",
273273
" result = time.time()-start\n",
274274
"\n",
@@ -354,7 +354,7 @@
354354
},
355355
"outputs": [],
356356
"source": [
357-
"ds_tensors = ds_tensors.map(tf.square).shuffle(2).batch(2)\n",
357+
"ds_tensors = ds_tensors.map(tf.math.square).shuffle(2).batch(2)\n",
358358
"\n",
359359
"ds_file = ds_file.batch(2)"
360360
]

0 commit comments

Comments
 (0)