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
🌐
Stack Overflow
stackoverflow.com › questions › 62785773 › attributeerror-numpy-ndarray-object-has-no-attribute-assert-compile-was-cal
python - AttributeError: 'numpy.ndarray' object has no attribute '_assert_compile_was_called' - Stack Overflow
how fix this problem. i think this the type of update error. please help to resolve this. result = np.apply_along_axis(augment, axis=1, arr=X[C3]).reshape(-1, 187) classe = np.ones(shape=(result.sh...
🌐
GitHub
github.com › waylandy › phosformer › issues › 1
'numpy.ndarray' object has no attribute 'numpy'. · Issue #1 · waylandy/phosformer
November 16, 2023 - Traceback (most recent call last): File "/Users/joshuasacher/phosformer/wip1_S234.py", line 17, in <module> predictions = Phosformer.predict_many( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joshuasacher/phosformer/Phosformer/modules.py", line 204, in predict_many return np.array([i['pred'] for i in batch_job(kinases, peptides, **kwargs)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joshuasacher/phosformer/Phosformer/modules.py", line 204, in <listcomp> return np.array([i['pred'] for i in batch_job(kinases, peptides, **kwargs)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joshuasacher/phosformer/Phosformer/modules.py", line 96, in batch_job pred = softmax(result['logits'].cpu(), axis=1)[:,1].numpy() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'numpy.ndarray' object has no attribute 'numpy'.
Author   jrsacher
Discussions

scikit learn - AttributeError: 'numpy.ndarray' object has no attribute 'fit' - Data Science Stack Exchange
I am relatively new to ML and in the process of learning pipelines. I am creating a pipeline of custom transformers and get this error: AttributeError: 'numpy.ndarray' object has no attribute 'fit'. More on datascience.stackexchange.com
🌐 datascience.stackexchange.com
September 24, 2021
Medical Data Visualizer AttributeError: 'numpy.ndarray' object has no attribute
I completed the project on google colab and everything seems to be working once I copy it over to replit. The charts seem to look good. However, I’m getting the following 2 errors on test: ====================================================================== ERROR: test_bar_plot_number_of_bars ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
May 11, 2023
Error creating numpy v-stack, 'AttributeError: 'numpy.ndarray' object has no attribute 'np'
I think I'm using the wrong notation to append to the empty arrays: The best way to find out is to read the documentation https://numpy.org/doc/stable/reference/generated/numpy.append.html And yes you are. Numpy arrays don't have an append method, it's a function from the library. And there is no such thing as object.library.function(...) which is what you are doing here similarity.np.append(...) num_interactions.np.append(...) It should be similarity = np.append(similarity, values_to_append) num_interactions = np.append(num_interactions, values_to_append) And should avoid appending data to a numpy array. I'm almost sure there is much better alternative. But since you didn't explain what you are trying to do, I can't help you with that. More on reddit.com
🌐 r/learnpython
5
2
May 4, 2021
Python Coding help- keep recieving error message"AttributeError: 'numpy.ndarray' object has no attribute 'MESSAGE_A'"
You should not be accessing dataframe columns with the dot notation. This is one of the reasons why. Use uplift_df['MESSAGE_A']. More on reddit.com
🌐 r/learnpython
9
18
October 16, 2022
🌐
Edureka Community
edureka.co › home › community › categories › python › assertionerror class numpy ndarray
AssertionError class numpy ndarray | Edureka Community
December 2, 2020 - I am having Time Series data in my data frame (dataset) after indexing by date when I am ... axis=axis)) AssertionError:
🌐
Reddit
reddit.com › r/learnpython › error creating numpy v-stack, 'attributeerror: 'numpy.ndarray' object has no attribute 'np'
r/learnpython on Reddit: Error creating numpy v-stack, 'AttributeError: 'numpy.ndarray' object has no attribute 'np'
May 4, 2021 -

Hi,

I'm trying to create a numpy v-stack and creating 3 np.array's for it, by filling them with a loop:

I get the error: 'AttributeError: 'numpy.ndarray' object has no attribute 'np' . I think I'm using the wrong notation to append to the empty arrays:

neighbor_id = [id_ for id_ in range(1, n_obs) if id_ != user_id]

neighbor_id_arr = np.array(neighbor_id)

similarity = np.array([])

num_interactions = np.array([])

# get similarity and num_interactions

for id_ in neighbor_id:

similarity.np.append(np.dot(user_item.loc[user_id],user_item.loc[id_])) #The issue is here, I think

num_interactions.np.append(user_interactions.loc[id_])

c = numpy.vstack((neighbor_id_arr, similarity,num_interactions))

Thanks!
James

Find elsewhere
🌐
GitHub
github.com › Zulko › moviepy › issues › 2102
AttributeError: 'numpy.ndarray' object has no attribute 'point' · Issue #2102 · Zulko/moviepy
January 26, 2024 - AttributeError Traceback (most recent call last) [<ipython-input-6-e96ac98275c5>](https://localhost:8080/#) in <cell line: 1>() ----> 1 video0 = video0.fl_image(tes) 9 frames <decorator-gen-178> in set_make_frame(self, mf) <decorator-gen-128> in get_frame(self, t) [/usr/local/lib/python3.10/dist-packages/pilgram2/css/brightness.py](https://localhost:8080/#) in brightness(im, amount) 40 assert amount >= 0 41 ---> 42 return im.point(lambda x: round(x * amount)) AttributeError: 'numpy.ndarray' object has no attribute 'point'
Author   sugizo
🌐
MNE Forum
mne.discourse.group › support & discussions
AttributeError: 'numpy.ndarray' object has no attribute 'get' - Support & Discussions - MNE Forum
May 17, 2021 - MNE-Python version: 0.23.0 operating system: Ubuntu 18.04.5 LTS -IDE: Pycharm-community import matplotlib import matplotlib.pyplot as plt import mne import numpy matplotlib.use('Qt5Agg') mne.set_log_level('warning') # Load raw data data_path = '/MNE/BrainVision/3.vhdr' raw = mne.io.read_raw_brainvision(data_path, preload=True, verbose=False) raw.info['line_freq'] = 50.
Top answer
1 of 4
134

If you debug your program by simply printing ax, you'll quickly find out that ax is a two-dimensional array: one dimension for the rows, one for the columns.

Thus, you need two indices to index ax to retrieve the actual AxesSubplot instance, like:

ax[1,1].plot(...)

If you want to iterate through the subplots in the way you do it now, by flattening ax first:

ax = ax.flatten()

and now ax is a one dimensional array. I don't know if rows or columns are stepped through first, but if it's the wrong around, use the transpose:

ax = ax.T.flatten()

Of course, by now it makes more sense to simply create each subplot on the fly, because that already has an index, and the other two numbers are fixed:

for x < plots_tot:
     ax = plt.subplot(nrows, ncols, x+1)

Note: you have x <= plots_tot, but with x starting at 0, you'll get an IndexError next with your current code (after flattening your array). Matplotlib is (unfortunately) 1-indexed for subplots. I prefer using a 0-indexed variable (Python style), and just add +1 for the subplot index (like above).

2 of 4
12

The problem here is with how matplotlib handles subplots. Just do the following:

fig, axes = plt.subplots(nrows=1, ncols=2)
for axis in axes:
    print(type(axis))

you will get a matplotlib object which is actually a 1D array which can be traversed using single index i.e. axis[0], axis[1]...and so on. But if you do

fig, axes = plt.subplots(nrows=2, ncols=2)
for axis in axes:
    print(type(axis))

you will get a numpy ndarray object which is actually a 2D array which can be traversed only using 2 indices i.e. axis[0, 0], axis[1, 0]...and so on. So be mindful how you incorporate your for loop to traverse through axes object.

🌐
GitHub
github.com › lmcinnes › umap › issues › 894
AttributeError: 'numpy.ndarray' object has no attribute 'transform' · Issue #894 · lmcinnes/umap
July 27, 2022 - Hello, When trying to do a .fit_transform on the "Train" data and then a .transform on the "Test" data, I get the error: AttributeError: 'numpy.ndarray' object has no attribute 'transform' This is my use case: reducer = umap.UMAP( n_comp...
Author   rbsingh13
🌐
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
Answer: The error is exactly what it says on the tin: NumPy’s ndarray object has no attribute [code ]append[/code] defined in its API. The error in question, for reference. We can start by asking, what is a numpy.ndarray? NumPy is an incredibly useful library for data manipulation in Python, wh...
🌐
freeCodeCamp
forum.freecodecamp.org › python
Attribute error during testing - Python - The freeCodeCamp Forum
October 5, 2021 - Tell us what’s happening: The test module fails giving the error 'numpy.ndarray' object has no attribute 'get_xlabel'. A very similar error comes up in the second test. Additionally for some reasons the values in my cor…
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-numpy-ndarray-object-has-no-attribute-append
How to Fix: ‘numpy.ndarray’ object has no attribute ‘append’ - GeeksforGeeks
November 28, 2021 - In the above output, we can see that the python list has a data type of list. When we perform the append operation, the item i.e., 5 gets appended to the end of the list `pylist`. While we try the same method for the NumPy array, it fails and throws an error "AttributeError: 'numpy.ndarray' object has no attribute 'append'".
🌐
NVIDIA
docs.nvidia.com › aerial › framework › latest › _modules › numpy.html
numpy — Aerial Framework
warnings("ignore", message="numpy.dtype size changed") warnings.filterwarnings("ignore", message="numpy.ufunc size changed") warnings.filterwarnings("ignore", message="numpy.ndarray size changed") # oldnumeric and numarray were removed in 1.9. In case some packages import # but do not use them, we define them here for backward compatibility. oldnumeric = 'removed' numarray = 'removed' def __getattr__(attr): # Warn for expired attributes, and return a dummy function # that always raises an exception. import warnings import math try: msg = __expired_functions__[attr] except KeyError: pass else: