我有以下模型:
col1 col2 ... col 4
1 0 2
0 0 2
2 1 1
我的Y具有以下格式:
y = to_categorical(Y).reshape(4, -1, 3)
并通过以下方式重塑:
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 4 array(s), but instead got the following list of 1 arrays:
[array([[[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
但是,在运行fit命令时,出现以下错误:
Array
(
[0] => Array
(
[weight] => 20
)
[1] => Array
(
[weight] => 15
)
[2] => Array
(
[weight] => 40
)
)
答案 0 :(得分:1)
假设Y是一个numpy矩阵? 试试这个:
y = [to_categorical(Y[:, col_numb]).reshape(-1, 3) for col_numb in range(Y.shape[1])]