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

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.

主站蜘蛛池模板: 新绛县| 禹州市| 大姚县| 青岛市| 茂名市| 丽水市| 阳谷县| 石阡县| 石家庄市| 邹城市| 乐安县| 安宁市| 肇庆市| 女性| 洛扎县| 珲春市| 卓资县| 亳州市| 绥德县| 仁布县| 大荔县| 松原市| 铜鼓县| 奉化市| 师宗县| 城步| 得荣县| 河源市| 长兴县| 文昌市| 武夷山市| 南城县| 高清| 渝中区| 上林县| 油尖旺区| 梅州市| 济阳县| 孝昌县| 泰州市| 麻城市|