adv_ex is already a numpy array, so you can’t call .numpy() again on it (which is a tensor method). Store adv_ex as a tensor or avoid calling numpy on it: adv_ex = perturbed_data.squeeze().detach().cpu() adv_examples.append( (init_pred.item(), final_pred.item(), adv_ex) ) Answer from ptrblck on discuss.pytorch.org
🌐
Quora
quora.com › Why-do-I-get-numpy-ndarray-object-has-no-attribute-append-error
Why do I get “numpy.ndarray object has no attribute append error”? - Quora
Take note that these methods are stored in the numpy module and not the numpy.ndarrays class, hence why there is no append attribute defined for the ndarray object. My guess is that this is to clarify that a new array is being generated and returned, not that the original array is modified. In Python, an attribute is anything that follows a dot after the object, which include data attributes (arr.shape) and methods (arr.flatten()).
Discussions

python 2.7 - Tensorflow error using tf.image.random : 'numpy.ndarray' object has no attribute 'get_shape' - Stack Overflow
0 TensorFlow official documentation tutorial error ''numpy.ndarray' object has no attribute 'get_shape' More on stackoverflow.com
🌐 stackoverflow.com
python - AttributeError: 'numpy.ndarray' object has no attribute 'get_shape'? - Stack Overflow
--> 592 outputs = self.call(inputs, ... context.executing_eagerly(): --> 555 outputs.set_shape(self.compute_output_shape(inputs.get_shape())) 556 return outputs 557 AttributeError: 'numpy.ndarray' object has no attribute 'get_shape'... More on stackoverflow.com
🌐 stackoverflow.com
tensorflow - Python - AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes' - Stack Overflow
Traceback (most recent call last): File "intermediate.py", line 12, in model.add(Conv2D(64,(3,3),input_shape = X.input_shapes[:1])) AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes' More on stackoverflow.com
🌐 stackoverflow.com
April 10, 2019
AttributeError: 'Array' object has no attribute 'shape'
There was an error while loading. Please reload this page · I use @generated_jit(nopython=True) More on github.com
🌐 github.com
8
March 21, 2022
🌐
GitHub
github.com › tensorflow › tensorflow › issues › 1399
Error using tf.image.random._ : 'numpy.ndarray' object has no attribute 'get_shape' · Issue #1399 · tensorflow/tensorflow
March 6, 2016 - AttributeError: 'numpy.ndarray' object has no attribute 'get_shape' My Tensor "images" is an ndarray (shape=[batch, im_size, im_size, channels]) of "batch" ndarrays (shape=[im_size, im_size, channels]). Just to check if my input data was packed in the right shape and type, I have tried to apply this simple function in the (not modified) tutorial "Tensorflow Mechanics 101" and I get the same error.
🌐
Stack Overflow
stackoverflow.com › questions › 55617533 › python-attributeerror-numpy-ndarray-object-has-no-attribute-input-shapes
tensorflow - Python - AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes' - Stack Overflow
April 10, 2019 - import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D import pickle X = pickle.load(open("X.pickle","rb")) y = pickle.load(open("y.pickle","rb")) X = X/255.0; model = Sequential() model.add(Conv2D(64,(3,3),input_shape = X.input_shape[:1])) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2,2))) model.add(Conv2D(64),(3,3)) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2,2))) model.add(Flatten()) model.add(Dense(64)) model.add(Activation("sigmoid")) model.compile(loss="binary_crossentropy", optimizer = "data", metrics=['accuracy']) model.fit(X,y,batch_size = 32, validation_split = 0.1)
🌐
GitHub
github.com › numba › numba › issues › 6984
AttributeError: 'Array' object has no attribute 'shape' · Issue #6984 · numba/numba
March 21, 2022 - @generated_jit(nopython=True) def letterbox(img, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleFill=False, scaleup=True): # Resize image to a 32-pixel-multiple rectangle https://github.com/ultralytics/yolov3/issues/232 shape = img.shape[:2] # current shape [height, width] if isinstance(new_shape, int): new_shape = (new_shape, new_shape) # Scale ratio (new / old) r = min(new_shape[0] / shape[0], new_shape[1] / shape[1]) if not scaleup: # only scale down, do not scale up (for better test mAP) r = min(r, 1.0) # Compute padding ratio = r, r # width, height ratios new_unpad = int(rou
Author   azuryl
Find elsewhere
🌐
PyTorch Forums
discuss.pytorch.org › t › attributeerror-numpy-ndarray-object-has-no-attribute-dim › 16026
AttributeError: 'numpy.ndarray' object has no attribute 'dim' - PyTorch Forums
April 5, 2018 - Hello Team, i am new to the forum and to Pytorch, i want to predict 3 real values Y1, Y2 & Y3 from input values X1, X2…X10 using the below model, but i get the error in title: File “/home/abdelmoula/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py”, line 833, in linear if input.dim() == 2 and bias is not None: AttributeError: ‘numpy.ndarray’ object has no attribute ‘dim’ Can you please on what is wrong ? thank you ######################## MODEL: import pandas as pd import to...
🌐
GitHub
github.com › cleverhans-lab › cleverhans › issues › 1235
'get_shape' Attribute · Issue #1235 · cleverhans-lab/cleverhans
May 12, 2023 - Describe the bug when I use optimize_linear function from utils.py. I get the following error: 'numpy.ndarray' object has no attribute 'get_shape' When I check the code there was no function definition for attribute get_shape. To Reprodu...
Published   May 12, 2023
Author   amissafari
🌐
Edureka Community
edureka.co › home › community › categories › python › attributeerror numpy ndarray object has no...
AttributeError numpy ndarray object has no attribute append | Edureka Community
August 10, 2020 - x_train=[] y_train=[] for i in range(8,64): x_train.append(trs[i-8:i,0]) ... ) AttributeError: 'numpy.ndarray' object has no attribute 'append'
🌐
GitHub
github.com › tensorflow › tensorflow › issues › 1409
Image ops do not all accept NumPy arrays as arguments · Issue #1409 · tensorflow/tensorflow
March 6, 2016 - AttributeError: 'numpy.ndarray' object has no attribute 'get_shape' My Tensor "images" is an ndarray (shape=[batch, im_size, im_size, channels]) of "batch" ndarrays (shape=[im_size, im_size, channels]).
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.ndarray.shape.html
numpy.ndarray.shape — NumPy v2.2 Manual
Setting arr.shape is discouraged and may be deprecated in the future. Using ndarray.reshape is the preferred approach.
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_ndarray_shape_attribute.htm
NumPy ndarray.shape Attribute
In this example, we create a simple 1-dimensional array and use the shape attribute to get the shape of the array − · import numpy as np # Creating a 1-dimensional array arr = np.array([1, 2, 3, 4]) print(arr.shape)
🌐
Reddit
reddit.com › r/learnpython › attribute error numpy.ndarray object has no attribute 'vectorize'
r/learnpython on Reddit: Attribute error numpy.ndarray object has no attribute 'vectorize'
September 15, 2019 -
Recoding Variables
"
#I need to recode variables given there are "5" responses present on a 4-point scale
scldict = {1:1,2:2,3:3,4:4,5:'NaN'}
w1array = np.array(week1)
w1vec = w1array.vectorize(scldict)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-92-e3f6056d2727> in <module>()
      2 scaldict = {1:1,2:2,3:3,4:4,5:'NaN'}
      3 w1array = np.array(week1)
----> 4 w1vec = w1array.vectorize(scaldict)

AttributeError: 'numpy.ndarray' object has no attribute 'vectorize'

Hello world, I am trying to recode variables given there are invalid responses in my survey data. I am using a dictionary and the vectorize function (seen on StackOverflow) to do this. Why is the vectorize function not available? I am lost.

Any help or suggestions for recoding variables in an efficient manner would be appreciated.