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

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.

主站蜘蛛池模板: 青州市| 龙南县| 沅陵县| 穆棱市| 眉山市| 崇信县| 伊金霍洛旗| 普格县| 贵德县| 深泽县| 平谷区| 晴隆县| 吴旗县| 桃园县| 舟曲县| 平潭县| 齐齐哈尔市| 太湖县| 龙口市| 法库县| 竹北市| 宣威市| 吴川市| 漳浦县| 和平区| 修武县| 康平县| 砚山县| 长汀县| 安多县| 包头市| 盈江县| 武汉市| 班玛县| 松原市| 八宿县| 台安县| 宜宾市| 三穗县| 灵石县| 衡山县|