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

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.

主站蜘蛛池模板: 沂南县| 邻水| 绥棱县| 原平市| 临西县| 东台市| 揭东县| 祁连县| 定南县| 梁河县| 新乐市| 临泉县| 屏东县| 天津市| 姜堰市| 浮梁县| 永和县| 望谟县| 佛山市| 松阳县| 邢台市| 孟州市| 永登县| 杭锦后旗| 华亭县| 大安市| 文山县| 泾阳县| 太仓市| 耒阳市| 西乌珠穆沁旗| 东乡族自治县| 武宁县| 花垣县| 迭部县| 青海省| 泽州县| 湖北省| 萨迦县| 灵台县| 普安县|