✡︎tensorflow中的切片

import tensorflow as tf
x = tf.constant([[1,2,3],[3,5,6],[3,40,9]])
sess = tf.Session()
print(sess.run(x[0:3]))
print('===================')
print(sess.run(x[0:2]))
print('===================')
print(sess.run(x[..., 0:2]))
=============================================
[[ 1  2  3]
 [ 3  5  6]
 [ 3 40  9]]
===================
[[1 2 3]
 [3 5 6]]
===================
[[ 1  2]
 [ 3  5]
 [ 3 40]]

    原文作者:胡今朝
    原文地址: https://zhuanlan.zhihu.com/p/45642039
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞