作者:手机用户2702934324 | 来源:互联网 | 2023-09-04 03:08
原文地址:https:blog.csdn.netuestc_c2_403articledetails73350457由于tensorflow版本更新问题用法略有修改tf.split
原文地址:
https://blog.csdn.net/uestc_c2_403/article/details/73350457
由于tensorflow 版本更新问题 用法略有修改
----------------------------------------------------------------------------------
tf.split(input, num_split, dimension):
dimension的意思就是输入张量的哪一个维度,如果是0就表示对第0维度进行切割。num_split就是切割的数量,如果是2就表示输入张量被切成2份,每一份是一个列表。
例如:
import tensorflow as tf;
import numpy as np;
A = [[1,2,3],[4,5,6]]
x = tf.split(A, 3, 1)
with tf.Session() as sess:
c = sess.run(x)
for ele in c:
print( ele )
输出:
[[1]
[4]]
[[2]
[5]]
[[3]
[6]]
注意:这个程序安装的tf版本是0.12.0,版本不同会有改动的,也就是函数用法会不同,注意一下子。
---------------------------------------------------------------------------------------------------------------------
import tensorflow as tf;
import numpy as np;
A = [[1,2,3],[4,5,6]]
x = tf.split(A, 2, 0)
with tf.Session() as sess:
c = sess.run(x)
for ele in c:
print( ele )
输出 :
[[1 2 3]]
[[4 5 6]]