使用tensorflow 1.8
我有一个RNN,我试图填充,然后将功能切片到可变长度的规范化句子
# param.batch_size = 32 params.max_doc_len = 10
# features is of shape [32, 800+]
features = tf.sparse_tensor_to_dense(features, default_value=0)
features = tf.Print(features, [tf.shape(features), features], "Features after sparse2dense")
features = tf.pad(features, tf.constant([[0, 0], [0, params.max_doc_len]]), "CONSTANT")
features = tf.Print(features, [tf.shape(features), features], "Features after pad")
# same output with
# features = features[:, :params.max_doc_len]
features = tf.strided_slice(features, [0,0], [params.batch_size, params.max_doc_len], [1,1])
features = tf.Print(features, [tf.shape(features), features], "Features after pad and drop")
Run Code Online (Sandbox Code Playgroud)
但是在切片时我得到了错误的尺寸:
Features after sparse2dense[32 858][[1038 5 104]...]
Features after …Run Code Online (Sandbox Code Playgroud)