当我尝试训练我的模型时,我得到如下Keras值错误
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 14 arrays:
[array([['0'],
['0'],
['0'],
['0'],
['0'],
['0'],
['0'],
['0'],
['1'],
['0'],
['0'],
['0'],
['0'],
['0'],
...
当我尝试使用以下方法重塑yïcol时:
y_col = np.stack( y_col, axis=0 )
我得到:
TypeError: If class_mode="multi_output", y_col must be a list. Received ndarray.
如果我只是想和你在一起
y_col = np.array(y_col)
我也有同样的错误
数据帧:
Path black grey green blue etc....
0 12345.jpg 1 0 1 0
1 12345.jpg 0 0 1 0
2 12345.jpg 1 0 0 1
3 12345.jpg 0 1 0 1
4 12345.jpg 0 0 1 1
5 12345.jpg 0 0 1 1
每个图像的模型应该是一个由14个元素组成的数组[0,0,1,1,0,1,0,…],但是看起来您为每个图像传递了14个不同的数组
问题发生在CNN网络上,它能识别产品(衣服)的颜色 一种产品可以有多种颜色,例如[0.0,0,1,0,1,0,0,1]
一开始你看起来:
['beige',
'black',
'blue',
'brown',
'gray',
'green',
'multicolor',
'orange',
'pink',
'red',
'violet',
'white',
'yellow',
'transparent']
发电机:
def get_generator(filename, number=None):
#
df = pd.read_csv(filename, delimiter=' ', names=color_list, dtype="str")
if number:
df = df[:number]
#
gen = image.ImageDataGenerator()
#
directory = os.path.dirname(filename)
#
return gen.flow_from_dataframe(df, directory, "path", y_col = y_col , target_size=(224, 224), batch_size=32,class_mode="multi_output")
y_col
是包含numpy
数组的列表。使用:
或一行:
输出:
相关问题 更多 >
编程相关推荐