In [11]:
import tensorflow as tf
import numpy as np
import gzip
import pickle
In [7]:
ph = tf.placeholder(shape=[None,3], dtype=tf.int32)
# look the -1 in the first position
x = tf.slice(ph, [0, 0], [-1, 2])
input_ = np.array([[1,2,3],
[3,4,5],
[5,6,7]])
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
print(sess.run(x, feed_dict={ph: input_}))
In [29]:
input_ = np.array([[1,2,0,0,0,0,0,0,0,0],[3,4,0,0,0,0,0,0,0,0]])
In [30]:
input_
Out[30]:
In [31]:
input_.shape
Out[31]:
In [32]:
ph = tf.placeholder(shape=[None,10],dtype=tf.int32)
In [33]:
x = tf.slice(ph,[0,0],[-1,2])
In [34]:
x
Out[34]:
In [35]:
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(x, feed_dict={ph: input_}))
In [ ]: