2017-12-06 4 views
2

Tensorflowのベクトルと行列を印刷しています。それはscalarを出力しますが、vectorMatrixTensorunhashableタイプ:印刷時に 'list' Tensorflowベクトル

コードのエラーを示し下回る:

import tensorflow as tf  
scalar = tf.constant([2]) 
vector = tf.constant([3,4,5]) 
Matrix = tf.constant([1,2,3],[4,5,6],[7,8,9]) 
Tensor = tf.constant([ [[1,2,3],[4,5,6],[7,8,9]], 
         [[1,2,3],[4,5,6],[7,8,9]], 
         [[1,2,3],[4,5,6],[7,8,9]] ]) 
with tf.Session() as session: 
    result = session.run(scalar) 
    print (result) 
    result = session.run(vector) 
    print (result) 
    result = session.run(Matrix) 
    print (result) 
    result = session.run(Tensor) 
    print (result) 

私は次のエラーを取得する:

TypeError: unhashable type: 'list' 

私はこれをどのように解決することができますか?

答えて

1

あなたはあなたの第四のステートメントでエラーが発生している: 使用

Matrix = tf.constant([ [1,2,3],[4,5,6],[7,8,9] ]) 
#     ^extra parenthesis here 

代わりの

Matrix = tf.constant([1,2,3],[4,5,6],[7,8,9]) 
+0

は答えをいただき、ありがとうございます。 –

+0

@ShekharKoirala助けて嬉しいです。受諾して答えをupvoteすることを忘れないでください:) –

関連する問題