import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
a = tf.constant(1)
b = tf.constant(2)
c = tf.add(a, b)
sess = tf.Session()
sess.run(c)
此代码显示:
WARNING:tensorflow:From
C:\Users\alsgn\anaconda3\lib\site-
packages\tensorflow\python\compat\v2_compat.py:107:
disable_resource_variables (from
tensorflow.python.ops.variable_scope) is deprecated and
will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long
term
2022-10-19 00:58:09.139243: I
tensorflow/core/platform/cpu_feature_guard.rd.cc:193]
This TensorFlow binary is optimized with oneAPI Deep
Neuraltwo Network Library (oneDNN) to use the following
CPU instructions in perce-formance-critical operations:
AVX AVX2
To enable them in other operations, rebuild TensorFlow
with the appropriariate compiler flags.
2022-10-19 00:58:09.427606: I
tensorflow/core/common_runtime/gpu/gpu_devievice.cc:1616]
Created device /job:localhost/replica:0/task:0/device:G0 wPU:0 with 5467 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3070bus, pci bus id: 0000:01:00.0, compute capability: 8.6
2022-10-19 00:58:09.429852: I tensorflow/compiler/mlir/mlir_graph_optimizmization_pass.cc:354] MLIR V1 optimization pass is not enabled
这看起来不是错误,但是代码没有输出结果。
1条答案
按热度按时间plicqrtu1#
您的代码运行正常。请使用
print()
函数获得如下结果输出量: