This is my code:
image_array.append(image)
label_array.append(i)
image_array = np.array(image_array)
label_array = np.array(label_array, dtype="float")
This is the error:
AttributeError: 'numpy.ndarray' object has no attribute 'append'
CodePudding user response:
From what I can recall, you are writing the append in the wrong way (check here the example in the doc https://numpy.org/doc/stable/reference/generated/numpy.append.html)
image_array = np.append(image_array, [image])
label_array = np.append(label_array, [i])
Arrays must have the same dimensions
CodePudding user response:
numpy.append expects two input atleast. see this example
import numpy as np
#define NumPy array
x = np.array([1, 4, 4, 6, 7, 12, 13, 16, 19, 22, 23])
#append the value '25' to end of NumPy array
x = np.append(x, 25)
#view updated array
x
array([ 1, 4, 4, 6, 7, 12, 13, 16, 19, 22, 23, 25])