110、TensorFlow张量值的计算
import tensorflow as tf #placeholders在没有提供具体值的时候不能使用eval方法来计算它的值 # 另外的建模方法可能会使得模型变得复杂 # TensorFlow 不能再session还没有开启的时候就计算张量的值 p = tf.placeholder(tf.float32) t = p + 1.0 init = tf.global_variables_initializer() with tf.Session() as sess: print(t.eval(feed_dict={p:2.0}))
下面是计算的结果
2018-02-16 21:46:48.085119: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 [1 4 9]
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步