tensorflow錯誤記錄:tf.concat

Candy_GL發表於2018-10-19

版權宣告:本文為博主原創文章,未經博主允許不得轉載。    https://blog.csdn.net/zcf1784266476/article/details/71248799

錯誤提示:

python TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

錯誤原因:

tensorflow版本的問題:

tensorflow1.0及以後api定義:(數字在後,tensors在前)

tf.stack(tensors, axis=axis)
For example:

t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
tf.concat([t1, t2], 0) ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
tf.concat([t1, t2], 1) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]

# tensor t3 with shape [2, 3]
# tensor t4 with shape [2, 3]
tf.shape(tf.concat([t3, t4], 0)) ==> [4, 3]
tf.shape(tf.concat([t3, t4], 1)) ==> [2, 6]
tensorflow之前版本(0.x版本:數字在前,tensors在後)
For example:


t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
tf.concat(0,[t1, t2], 0)
tf.concat(1,[t1, t2], 1)

解決方法:

調整tf.concat函式中引數位置即可.

--------------------- 
作者:Devil_Satan 
來源:CSDN 
原文:https://blog.csdn.net/zcf1784266476/article/details/71248799 
版權宣告:本文為博主原創文章,轉載請附上博文連結!

相關文章