Usage [Reserved] tf.split function

Original Address:

https://blog.csdn.net/uestc_c2_403/article/details/73350457

 

 

Since tensorflow updated version problem   usage slightly modified

----------------------------------------------------------------------------------

 

 

 

 

tf.split(input, num_split, dimension):

dimension input which means that one dimension tensor, if it is 0 0 means that the first cutting dimensions. num_split is cutting the number of, if it means 2 is input tensor is cut into 2 parts, each one is a list.

 

 

 

E.g:

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 )

 

 

 

 

Output:

[[1]
 [4]]
[[2]
 [5]]
[[3]
 [6]]

Note: This program is installed tf version is 0.12.0, subject to change in a different version, which is a function of usage will be different, all of a sudden attention.

 

 

 

 

 

---------------------------------------------------------------------------------------------------------------------

 

 

 

 

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 )

 

 

 

 

 

Output:

[[1 2 3]]
[[4 5 6]]

 

Guess you like

Origin www.cnblogs.com/devilmaycry812839668/p/10960821.html