- TensorFlow 2.0 Quick Start Guide
- Tony Holdroyd
- 87字
- 2021-06-24 16:02:05
Finding the squared difference between two tensors
Later in this book, we will need to find the square of the difference between two tensors. The method is as follows:
tf.math.squared.difference( x, y, name=None)
Take the following example:
x = [1,3,5,7,11]
y = 5
s = tf.math.squared_difference(x,y)
s
The output will be as follows:
<tf.Tensor: id=279, shape=(5,), dtype=int32, numpy=array([16, 4, 0, 4, 36], dtype=int32)>
Note that the Python variables, x and y, are cast into tensors and that y is then broadcast across x in this example. So, for example, the first calculation is (1-5)2 = 16.
推薦閱讀
- 玩轉(zhuǎn)智能機(jī)器人程小奔
- Mastering Spark for Data Science
- Getting Started with MariaDB
- Mobile DevOps
- 數(shù)據(jù)運(yùn)營之路:掘金數(shù)據(jù)化時代
- 80x86/Pentium微型計算機(jī)原理及應(yīng)用
- 21天學(xué)通Visual Basic
- Maya極速引擎:材質(zhì)篇
- RPA(機(jī)器人流程自動化)快速入門:基于Blue Prism
- JavaScript典型應(yīng)用與最佳實踐
- 聊天機(jī)器人:入門、進(jìn)階與實戰(zhàn)
- 運(yùn)動控制系統(tǒng)
- Building a BeagleBone Black Super Cluster
- Spatial Analytics with ArcGIS
- Mastering OpenStack(Second Edition)