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

Operations

The TensorFlow library contains several built-in operations that can be applied on tensors. An operation node can be defined by passing input values and saving the output in another tensor. To understand this better, let's define two operations, op1 and op2:

op1 = tf.add(const2, const3)
op2 = tf.multiply(const2, const3)

Let's print op1 and op2:

print('op1 : ', op1)
print('op2 : ', op2)

The output is as follows, and shows that op1 and op2 are defined as tensors:

op1 :  Tensor("Add:0", shape=(), dtype=float32)
op2 : Tensor("Mul:0", shape=(), dtype=float32)

To print the output from executing these operations, the op1 and op2 tensors have to be executed in a TensorFlow session:

print('run(op1) : ', tfs.run(op1))
print('run(op2) : ', tfs.run(op2))

The output is as follows:

run(op1) :  91.0
run(op2) :  1888.0

Some of the built-in operations of TensorFlow include arithmetic operations, math functions, and complex number operations.

主站蜘蛛池模板: 泸西县| 商河县| 台中市| 雅安市| 定安县| 绥宁县| 泸溪县| 石台县| 建昌县| 河曲县| 桑日县| 廉江市| 枣庄市| 北安市| 合山市| 台州市| 富蕴县| 苍山县| 唐山市| 丰顺县| 辛集市| 永州市| 米林县| 绥芬河市| 藁城市| 襄汾县| 靖江市| 桦南县| 福鼎市| 贡嘎县| 高台县| 平泉县| 布尔津县| 上犹县| 色达县| 武威市| 哈密市| 台东县| 仪陇县| 改则县| 海原县|