I’m trying to use the test set to make predictions, and when I use the Predict () function, the system gets the error ‘ AttributeError: ‘numpy.ndarray’ object has no attribute ‘columns’ ‘, ‘x_test’ is a 4-dimensional Pepin dataset, how can I solve it?’ Here’s part of my code:
<code>from tensorflow.keras.utils import img_to_array
from tensorflow.keras.utils import array_to_img
from tensorflow.keras.utils import load_img
def convert_image_to_array(files):
images_as_array=[]
for file in files:
# Convert to Numpy Array
images_as_array.append(img_to_array(load_img(file)))
return images_as_array
x_test = np.array(convert_image_to_array(x_test))
print('Test set shape : ',x_test.shape)
</code>
<code>from tensorflow.keras.utils import img_to_array
from tensorflow.keras.utils import array_to_img
from tensorflow.keras.utils import load_img
def convert_image_to_array(files):
images_as_array=[]
for file in files:
# Convert to Numpy Array
images_as_array.append(img_to_array(load_img(file)))
return images_as_array
x_test = np.array(convert_image_to_array(x_test))
print('Test set shape : ',x_test.shape)
</code>
from tensorflow.keras.utils import img_to_array
from tensorflow.keras.utils import array_to_img
from tensorflow.keras.utils import load_img
def convert_image_to_array(files):
images_as_array=[]
for file in files:
# Convert to Numpy Array
images_as_array.append(img_to_array(load_img(file)))
return images_as_array
x_test = np.array(convert_image_to_array(x_test))
print('Test set shape : ',x_test.shape)
<code>x_test = x_test.astype('float32')/255
</code>
<code>x_test = x_test.astype('float32')/255
</code>
x_test = x_test.astype('float32')/255
<code>y_pred = model.predict(x_test)
</code>
<code>y_pred = model.predict(x_test)
</code>
y_pred = model.predict(x_test)
I tried converting the dataset to a Dataframe format, but the format can only accept two-bit arrays.
New contributor
Olga Sexton is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.