1 year ago

#269319

test-img

SAI SURYA TEJA KORIPELLA

boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1

I'm trying to solve Dimensionality reduction using PCA and T-SNE. I am stuck at this step. the error is " IndexError: boolean index did not match indexed array along dimension 0; dimension is 180000 but corresponding boolean dimension is 60000" i tried looking up online for possible solutions and i found solutions where it said to lower my version of tensior flow and keras and i did it but it did'nt work. i tried to look for more possible solutions but didnt find anything relevant.I am adding my code to this Question. Can anyone guide me with this?

from keras.datasets import cifar10
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from matplotlib import pyplot as plt
import numpy as np

%matplotlib inline

plt.rcParams['figure.figsize'] = [12, 9]

(x_train, x_test), (y_train, y_test) = cifar10.load_data()

train = np.concatenate((x_train, y_train))
test = np.concatenate((x_test, y_test))

(x_train.shape)

y_train

print(x_train.shape)
print(y_train.shape)
print(x_test.shape)
print(y_test.shape)

train=np.concatenate((x_train,y_train))
test=np.concatenate((x_test,y_test))
print(train.shape)
print(test.shape)

pca = PCA(n_components=2)

%%time
reduced = pca.fit_transform(train.reshape(-1, 32 * 32))

for i in range(10):
  num = reduced[test == i]
  plt.scatter(num[:, 0], num[:, 1], s=5, label=f'{i}')

plt.legend()
plt.show() 

IndexError: boolean index did not match indexed array along dimension 0; dimension is 180000 but corresponding boolean dimension is 60000

python

machine-learning

keras

pca

dimensionality-reduction

0 Answers

Your Answer

Accepted video resources