The error occurs because the "y_train" array is being used as keys in the dictionary, but numpy arrays are not hashable and cannot be used as keys. To fix this issue, you can convert the "y_train" array to a list before creating the dictionary. Here's the modified code:

dict_train = dict(zip(y_train.tolist(), x_train))
dict_test = dict(zip(y_test.tolist(), x_test))
np.save("./lalala1.npz", dict_train)
np.save("./lalala2.npz", dict_test)

By converting the "y_train" and "y_test" arrays to lists using the .tolist() method, you can create the dictionaries without any error

import numpy as npimport tensorflow as tffrom keraspreprocessingimage import ImageDataGeneratorimport osfrom PIL import Imagefrom kerasutils import to_categoricalfrom sklearnmodel_selection import tra

原文地址: https://www.cveoy.top/t/topic/h3X9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录