TensorFlow:如何为张量

时间:2017-09-05 02:24:14

标签: tensorflow subset tensor

我有以下代码:

import numpy as np
import tensorflow as tf

series = tf.placeholder(tf.float32, shape=[None, 5])
series_length = tf.placeholder(tf.int32, shape=[None])
useful_series = tf.magic_slice_function(series, series_length)

with tf.Session() as sess:
    input_x = np.array([[1, 2, 3, 0, 0],
                        [2, 3, 0, 0, 0],
                        [1, 0, 0, 0, 0]])
    input_y = np.array([[3], [2], [1]])
    print(sess.run(useful_series, feed_dict={series: input_x, series_length: input_y}))

预期输出如下

[[1,2,3],[2,3],[1]]

我尝试了几个函数,等等,tf.gather,tf.slice。所有这些都不起作用。 什么是 magic_slice_function

1 个答案:

答案 0 :(得分:1)

这有点棘手:

DataGrid

输出将是:

TabControl