When I subtract these two arrays, it returns a (354,354) shaped array because as per the documentation there is a mismatch in the shape of the arrays.
Why does it happen and what else can I do for this except numpy.reshape
?
Asked
Active
Viewed 170 times
-2

Chandraraj Singh
- 65
- 2
- 8
1 Answers
1
This is a problem that I have also run into before, right now your ytrain is a one dimensional array (advisable to avoid). Check this answer.
expanding(adding) additional dimension while assigning ytrain should fix your problem
x = np.array([1, 2])
x.shape
(2,)
y = np.expand_dims(x, axis=1)
y
array([[1],
[2]])
y.shape
(2, 1)

sai
- 219
- 1
- 5