float() argument must be a string or a number not map

win10下的python3程序報錯如題,

TypeError: float() argument must be a string or a number, not 'map'

具體出錯的語句:

image_batch = np.array(map(lambda x: ndimage.imread(x, mode='RGB'), image_batch_file)).astype(np.float32)

網上查到map外要加list(),改成下面語句就解決了:

image_batch = np.array(list(map(lambda x: ndimage.imread(x, mode='RGB'), image_batch_file))).astype(np.float32)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章