-4

Im trying to make a handwritten digit recognition program with machine learning. As the title says, i want to simple resize mnist dataset with cv2 library. And i want the resize to be done before normalizing the data, so that its the resized data that gets through my ANN(Artificial Neural Network) model. But im not really sure how to do that, this is the code i have:

model.add = modell
train = keras.utils.normalize(train)
test = keras.utils.normalize(test)
model=Sequential()
modell(Flatten())
modell(Dense(200, activation='sigmoid'))
modell(Dense(200, activation='sigmoid'))
modell(Dense(10, activation="sigmoid"))
model.fit(img, lab, epochs=1)
print(model.evaluate(test, test))
pred = model.predict(test[:1])
p=np.argmax(pred, axis=1)
print("Machine", p)
print("Correct", test[:1])

I have tried to put this in to my code, right before normalizing my data:

for i in train_img:
    photo = cv2.reshape(train_img[i] 19 19)
    img.append(photo)

But it gives me this error: TypeError: 'tuple' object is not callable

How do i do it?

Community
  • 1
  • 1
Peter Barnes
  • 79
  • 2
  • 9

1 Answers1

2

in your code i is in train_img. Therefore i is an image and can not be used as an index so try this

new_train_img = []
for img in train_img:
    new_train.append(cv2.resize(img,(14,14)))
Gerry P
  • 7,662
  • 3
  • 10
  • 20