0

私はfeed_dict(各バッチでの入力変更のディメンション)を使用して入力された入力の次元に基づいてテンソルをtf.splitしようとしています。現在、テンソルを「次元」で分割することはできないというエラーが発生し続けています。ディメンションの値を取得し、それを使用して分割する方法はありますか?Feed Dict入力ディメンションを使用したテンソルフローの分割

ありがとうございます!

input_d = tf.placeholder(tf.int32, [None, None], name="input_d") 

# toy feed dict 
feed = { 
    input_d: [[20,30,40,50,60],[2,3,4,5,-1]] # document 
} 

W_embeddings = tf.get_variable(shape=[vocab_size, embedding_dim], \ 
        initializer=tf.random_uniform_initializer(-0.01, 0.01),\ 
        name="W_embeddings") 
document_embedding = tf.gather(W_embeddings, input_d) 

timesteps_d = document_embedding.get_shape()[1] 
doc_input = tf.split(1, timesteps_d, document_embedding) 
+0

エラーメッセージは何ですかtf.Tensor.get_shapeのためのいくつかの関連するドキュメンテーションはありますか? 'seq_lens'の値を' document_embedding'で印刷できますか? – drpng

+0

'TypeError:引数 'num_split'に期待されるintではありません。Dimension(None)。 – kewzha

+0

' get_shape()。shape [1] 'はどうですか? – drpng

答えて

0

tf.splitnum_split引数にPythonの整数をとります。ただし、document_embedding.get_shape()TensorShapeを返し、document_embedding.get_shape()[1]Dimensionインスタンスを返します。したがって、「次元で分割できません」というエラーが表示されます。

timestep_ds = document_embedding.get_shape().as_list()[1]を試してみると、この文はあなたにpythonの整数を与えるはずです。

ここtf.split

関連する問題