We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00be3d2 commit aa47fe0Copy full SHA for aa47fe0
1 file changed
17tensorflow/tf2/8autograph.py
@@ -3,4 +3,22 @@
3
@author:XuMing([email protected])
4
@description:
5
"""
6
+import numpy as np
7
+import tensorflow as tf
8
+from tensorflow.python.ops import control_flow_util
9
+# 1.tf.function装饰器¶
10
+# 当使用tf.function注释函数时,可以像调用任何其他函数一样调用它。 它将被编译成图,这意味着可以获得更快执行,更好地在GPU或TPU上运行或导出到SavedModel。
11
+@tf.function
12
+def simple_nn_layer(x, y):
13
+ return tf.nn.softmax(tf.matmul(x, y))
14
15
+
16
+x = tf.random.uniform((3, 3))
17
+y = tf.random.uniform((3, 3))
18
19
+a = simple_nn_layer(x, y)
20
+print(a)
21
+with tf.GradientTape as tape:
22
+ logits = a
23
+b = logits
24
+print(b)
0 commit comments