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

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.

主站蜘蛛池模板: 阿图什市| 丹阳市| 衡山县| 连平县| 富源县| 云梦县| 沧州市| 靖安县| 乐亭县| 大悟县| 舟山市| 开阳县| 蚌埠市| 阳朔县| 洮南市| 白沙| 郁南县| 定边县| 通州区| 岳阳市| 邛崃市| 沅陵县| 钟祥市| 渑池县| 来安县| 东兰县| 红河县| 南雄市| 驻马店市| 章丘市| 同江市| 庆阳市| 崇州市| 苗栗县| 商水县| 隆尧县| 衡东县| 彩票| 巴南区| 讷河市| 乐平市|