首页 > 其他 > 详细

TensorFlow之tf.unstack学习循环神经网络中用到!

时间:2017-07-27 23:18:03      阅读:1395      评论:0      收藏:0      [点我收藏+]
unstack(
    value,
    num=None,
    axis=0,
    name=‘unstack‘
)

tf.unstack()  

  将给定的R维张量拆分成R-1维张量

  value根据axis分解成num个张量,返回的值是list类型,如果没有指定num则根据axis推断出!

DEMO:

import tensorflow as tf
a = tf.constant([3,2,4,5,6])
b = tf.constant([1,6,7,8,0])
c = tf.stack([a,b],axis=0)
d = tf.stack([a,b],axis=1)
e = tf.unstack([a,b],axis=0)
f = tf.unstack([a,b],axis=1)

with tf.Session() as sess:
    print(sess.run(c))
    print(sess.run(d))
    print(sess.run(e))
    print(sess.run(f))

  输出:

[[3 2 4 5 6]
[1 6 7 8 0]]

--------------------
[[3 1]
[2 6]
[4 7]
[5 8]
[6 0]]

----------------------
[array([3, 2, 4, 5, 6]), array([1, 6, 7, 8, 0])]

----------------------
[array([3, 1]), array([2, 6]), array([4, 7]), array([5, 8]), array([6, 0])]

 

TensorFlow之tf.unstack学习循环神经网络中用到!

原文:http://www.cnblogs.com/zhangshilin/p/7247776.html

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