I think I did the function and did the reshape and normalize as expected, but I keep
getting an error because of the images
parameter
AttributeError: ‘tuple’ object has no attribute ‘reshape’
I understand the error but I just couldn’t fix it
I think I did the function and did the reshape and normalize as expected, but I keep
getting an error because of the images
parameter
AttributeError: ‘tuple’ object has no attribute ‘reshape’
I understand the error but I just couldn’t fix it
(training_images), _ =
is causing the problems with the type. The example on the doc page looks like this
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
My guess is you need to account for the y_train
inside the first parens
Thanks a looot, it works
can you please explain to me what was happening and what adding y_train
to the parameter did?
First, I checked the doc page for that function
It shows the return structure that I pasted above. Then I checked the source code on github. It also provides details of the return type, which is a composite, tuple of NumPy arrays
Your code has the correct number of return objects at the highest level, which is 2 (one before the comma and one after the comma, which is using the underscore as a variable name). However, note that in the doc each of the two tuples returned is itself suppsed to have two values. Yours only has one so x_train
was created as a list of tuples instead of a tuple of arrays. You could prove this by printing out the type of x_train
before and after the ‘fix’
Python is very flexible with data types and always tries to do what you ask. It will create a list of tuples of arrays of lists or whatever complex data type it needs to, even when that isn’t what you expected