2016-07-13 8 views
2

私の訓練の例は、それぞれ長さの異なるリストです。 私はこれらの例をグラフに入力する方法を見つけようとしています。 以下は、要素が不明なディメンションを持つプレースホルダであるリストを作成して、そのようにしようとしたところです。Tensorflow - 異なる長さの例を与える

InvalidArgumentError: Shapes of all inputs must match: values[0].shape = [3,7] != values[1].shape = [3,2] 

それを解決する方法上の任意のアイデア:

graph2 = tf.Graph() 
with graph2.as_default(): 
    A = list() 
    for i in np.arange(3): 
     A.append(tf.placeholder(tf.float32 ,shape = [None,None])) 
    A_size = tf.shape(A) 

with tf.Session(graph=graph2) as session: 
    tf.initialize_all_variables().run() 
    feed_dict = {A[0]:np.zeros((3,7)) ,A[1] : np.zeros((3,2)) , A[2] : np.zeros((3,2)) } 
    print (type(feed_dict)) 
    B = session.run(A_size ,feed_dict=feed_dict) 
print type(B) 

は、しかし、私は次のエラーを得ましたか。

tf.placeholderのドキュメントから

答えて

2

:あなたはshape=None代わりのshape=[None, None]を記述する必要が

shape: The shape of the tensor to be fed (optional). If the shape is not specified, you can feed a tensor of any shape.

。あなたのコードでは、Tensorflowはあなたが可変サイズの入力を処理していることを知らない。

+0

動作していないようですが、以前と同じエラーが表示されます。 –

+0

どのラインでエラーが出ますか? –

関連する問題