RVC
RVC

Reputation: 29

Can anyone knows this error in python tensorflow?

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'

Upvotes: 0

Views: 56

Answers (2)

M Imran
M Imran

Reputation: 129

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])

Upvotes: 2

Marco Massetti
Marco Massetti

Reputation: 837

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

Upvotes: 1

Related Questions