import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
a = tf.constant([10.0, 20.0, 40.0], name='a')
b = tf.Variable(tf.random_uniform([3]), name='b') # 从均匀分布中输出随机值,[3]代表张量尺寸
output = tf.add_n([a, b], name='add') # Add all input tensors element wise
with tf.Session() as sess:
writer = tf.summary.FileWriter('../log', sess.graph)
# tf.RunOptions.FULL_TRACE代表所有的信息
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
# 运行时记录运行信息的proto,pb是用来序列化数据的
run_metadata = tf.RunMetadata()
sess.run(tf.global_variables_initializer())
f = sess.run(output, options=run_options, run_metadata=run_metadata)
print(f)
writer.add_run_metadata(run_metadata, 'metadata')
writer.close()
pass
tf1.x产出模型小例子
最新推荐文章于 2024-08-09 22:02:19 发布
该博客展示了如何在 TensorFlow 中使用 `tf.add_n` 进行元素级加法操作,并记录运行时信息。通过创建常量和变量,然后将它们传递给 `add_n` 函数,实现张量的相加。同时,利用 `tf.Session` 运行图并使用 `tf.summary.FileWriter` 记录会话图和运行元数据。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.15
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
1221

被折叠的 条评论
为什么被折叠?



