首页 > 其他 > 详细

获取tensorflow中tensor的值

时间:2018-07-23 12:14:01      阅读:991      评论:0      收藏:0      [点我收藏+]

tensorflow中的tensor值的获取:

import tensorflow as tf

#定义变量a
a=tf.Variable([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])

#定义索引
indics=[[0,0,0],[0,1,1],[0,1,2]]

#把a中索引为indics的值取出
b=tf.gather_nd(a,indics)

#初始化
init=tf.global_variables_initializer()
with tf.Session() as sess:
    #执行初始化
    sess.run(init)

    #打印结果
    print(a.eval())
    print(b.eval())

 

获取tensorflow中tensor的值

原文:https://www.cnblogs.com/shixisheng/p/9353757.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!