天天看點

成功解決TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed valu

解決問題

TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed values: int32, int64

解決思路

類型錯誤:傳遞給參數“paddings”的值,不包含允許的值清單中的資料類型, int32, int64,這兩種類型

對類型進行轉換:強制轉換為int類型

解決方法

建議采用np的int類型轉換!

x_padded = tf.pad(x, [[0, 0], [np.int(kernel / 2), np.int(kernel / 2)], [np.int(kernel / 2), np.int(kernel / 2)], [0, 0]], mode=mode)

哈哈,成功運作,大功告成!

繼續閱讀