126、TensorFlow Session的执行
# tf.Session.run 方法是一个执行tf.Operation或者计算tf.Tensor的一个主要的机制 # 你可以传递一个或者多个tf.Operation或者tf.Tensor对象来给tf.Session.run # TensorFlow会执行operation操作来计算结果 # tf.Session.run需要你来指定一系列的获取,这些决定了返回值 # 这些获取可以是 tf.Operation ,一个tf.Tensor 或者一个tensor-like type 列如tf.Variable # 这些获取决定了子的计算图必须执行的操作来产生结果 import tensorflow as tf x = tf.constant([[37.0, -23.0], [1.0, 4.0]]) w = tf.Variable(tf.random_uniform([2, 2])) y = tf.matmul(x, w) output = tf.nn.softmax(y) init_op = w.initializer with tf.Session() as sess: # Run the initializer on 'w' sess.run(init_op) # Evaluate 'output' , 'sess.run(output)' will return a NumPy array containing # the result of the computation print(sess.run(output)) # Evaluate 'y' and 'output' # y will only be computed once, # and its result used both to return # y_valu and as an input to the tf.nn.softmax() # op . both y_val and output_val will be NumPy arrays y_val, output_val = sess.run([y, output]) # print result print(y_val) print(output_val)
分类:
tensorflow
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
· 开发的设计和重构,为开发效率服务
· 从零开始开发一个 MCP Server!
· Ai满嘴顺口溜,想考研?浪费我几个小时
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
2017-02-17 64、saleforce 删除操作举例
2017-02-17 63、saleforce DML