Reputation: 13025
There is an existing train_labels, which has the following attributes
('labels_train shape ', (3000,))
('type of labels_train ', <type 'numpy.ndarray'>)
and another array is Y, which has the following attributes
('Y ', (3000,1))
('type of Y ', <type 'numpy.ndarray'>)
How to assign Y
to labels_train
, or how to make Y
has the same shape as labels_train
?
Upvotes: 0
Views: 1563
Reputation: 1426
You can use the squeeze
function:
Y = Y.squeeze()
This will remove the singleton dimension so that Y.shape
is (3000,)
.
Upvotes: 2
Reputation: 96
If you want to copy over the content from Y
to labels_train
, the following should work.
labels_train[:] = Y[:,0]
If you want to reshape Y
to have the same shape as labels_train
(this only works if they have the same number of elements).
Y = Y.reshape(labels_train.shape)
Upvotes: 2