真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

解決Tensorflow ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)

問(wèn)題描述

在將一個(gè)數(shù)組送入tensorflow訓(xùn)練時(shí),報(bào)錯(cuò)如下:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)
數(shù)組元素為數(shù)組,每個(gè)數(shù)組元素的shape不一致,示例如下:

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),南溪企業(yè)網(wǎng)站建設(shè),南溪品牌網(wǎng)站建設(shè),網(wǎng)站定制,南溪網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,南溪網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

cropImg[0].shape = (13, 13, 3)
cropImg[1].shape = (14, 13, 3)
cropImg[2].shape = (12, 13, 3)

環(huán)境

python 3.7.9
tensorflow 2.6.0
keras 2.6.0

解決方法

stackoverflow上有許多類似的報(bào)錯(cuò),大概意思都是數(shù)據(jù)類型錯(cuò)誤,轉(zhuǎn)換的數(shù)據(jù)類型報(bào)錯(cuò)中括號(hào)里的數(shù)據(jù)類型,如:
Unsupported object type numpy.ndarray指cropImg數(shù)組元素不是numpy.ndarray類型。
博主非常不解,嘗試了許多方法,都顯示cropImg數(shù)組元素?cái)?shù)據(jù)類型為numpy.ndarray,但錯(cuò)誤一直存在。
后來(lái)突然轉(zhuǎn)念,在生成cropImg數(shù)組時(shí),有一個(gè)warning:

VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  cropImg_ar = np.array(img_list)

cropImg數(shù)組元素為shape不一致的數(shù)組,這說(shuō)明cropImg數(shù)組元素類型實(shí)際上為object,會(huì)不會(huì)是tensorflow不接受object類型的數(shù)據(jù)導(dǎo)致的?
將cropImg數(shù)組元素轉(zhuǎn)換為shape一致后,問(wèn)題解決。

參考鏈接
https://stackoverflow.com/questions//valueerror-failed-to-convert-a-numpy-array-to-a-tensor-unsupported-object-type
https://stackoverflow.com/questions//tensorflow-valueerror-failed-to-convert-a-numpy-array-to-a-tensor-unsupporte
https://blog.csdn.net/liveshow021_jxb/article/details/


文章標(biāo)題:解決Tensorflow ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)
網(wǎng)站鏈接:http://weahome.cn/article/dsojcce.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部