官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 阿勒泰市| 梨树县| 大邑县| 河间市| 金乡县| 枣阳市| 双鸭山市| 巫山县| 饶平县| 新邵县| 怀远县| 宕昌县| 运城市| 静海县| 娱乐| 汾西县| 都安| 隆德县| 威远县| 平度市| 佛教| 北流市| 朔州市| 德令哈市| 茌平县| 武鸣县| 昭通市| 柘城县| 个旧市| 承德市| 太康县| 洪湖市| 仪陇县| 西丰县| 邵东县| 舟山市| 尼玛县| 崇阳县| 文水县| 靖安县| 芜湖市|