numpy-ufunc Questions
6
Solved
I'm looking for the most memory-efficient way to compute the absolute squared value of a complex numpy ndarray
arr = np.empty((250000, 150), dtype='complex128') # common size
I haven't found a...
Mouthy asked 25/5, 2015 at 12:3
3
Solved
I'd like to know if there is a more efficient/pythonic way to add multiple numpy arrays (2D) rather than:
def sum_multiple_arrays(list_of_arrays):
a = np.zeros(shape=list_of_arrays[0].shape) #init...
Exciter asked 9/2, 2021 at 1:18
2
Solved
Is it generally safe to provide the input array as the optional out argument to a ufunc in numpy, provided the type is correct? For example, I have verified that the following works:
>>> ...
Riyal asked 28/10, 2015 at 17:48
7
Solved
I am trying to convert a csv into numpy array. In the numpy array, I am replacing few elements with NaN. Then, I wanted to find the indices of the NaN elements in the numpy array. The code is :
im...
Carriecarrier asked 5/10, 2018 at 1:45
4
Solved
How do I convert a np.add.at statement into tensorflow?
np.add.at(dW, self.x.ravel(), dout.reshape(-1, self.D))
Edit
self.dW.shape is (V, D), self.D.shape is (N, D) and self.x.size is N
Boyhood asked 2/11, 2016 at 21:8
3
Solved
I'm working on cs231n and I'm having a difficult time understanding how this indexing works. Given that
x = [[0,4,1], [3,2,4]]
dW = np.zeros(5,6)
dout = [[[ 1.19034710e-01 -4.65005990e-01 8.93743...
Planetary asked 3/8, 2017 at 2:36
1
Running Numpy version 1.19.2, I get better performance cumulating the mean of every individual axis of an array than by calculating the mean over an already flattened array.
shape = (10000,32,32,3)...
Affectation asked 14/12, 2020 at 21:48
2
There is a positive function in numpy (version 1.13+), which seemingly does nothing:
In [1]: import numpy as np
In [2]: A = np.array([0, 1, -1, 1j, -1j, 1+1j, 1-1j, -1+1j, -1-1j, np.inf, -np.inf...
Snowbound asked 29/3, 2019 at 14:26
4
Solved
Relating to this answer, is there a fast way to compute medians over an array that has groups with an unequal number of elements?
E.g.:
data = [1.00, 1.05, 1.30, 1.20, 1.06, 1.54, 1.33, 1.87, 1.6...
Igor asked 10/11, 2019 at 11:9
1
Solved
I'm working on some code where I have several matrices and want to subtract a vector $v$ from each row of each matrix (and then do some other stuff with the result). As I'm using NumPy and want to ...
Latreese asked 11/7, 2019 at 21:12
1
Solved
I wonder if it is possible at all to perform element-wise sum (or other operations) of two structured numpy arrays of an identical shape.
arr1 = np.array([[1,2,3],[2,3,4]], dtype=[("x", "f8"),("y"...
Oenomel asked 4/2, 2019 at 14:7
2
Solved
Is it possible to use ufuncs https://docs.scipy.org/doc/numpy/reference/ufuncs.html
In order to map function to array (1D and / or 2D) and scalar
If not what would be my way to achieve this?
...
Rarely asked 26/11, 2018 at 16:22
2
I am trying to broadcast a simple operation of ">" over two 3D arrays. One has dimensions (m, 1, n) the other (1, m, n). If I change the value of the third dimension (n), I would naively expect tha...
Burnet asked 12/10, 2018 at 7:19
3
Solved
I measured performance of ufuncs like np.cumsum over different axes:
In [51]: arr = np.arange(int(1E6)).reshape(int(1E3), -1)
In [52]: %timeit arr.cumsum(axis=1)
2.27 ms ± 10.5 µs per loop (mean ±...
Globe asked 27/1, 2018 at 1:53
1
Solved
I've read a lot "avoid for loops with numpy". So, I tried. I was using this code (simplified version). Some auxiliary data:
In[1]: import numpy as np
resolution = 1000 # this parameter varies
t...
Hendiadys asked 26/12, 2016 at 0:13
1
Solved
From an array like db (which will be approximately (1e6, 300)) and a mask = [1, 0, 1] vector, I define the target as a 1 in the first column.
I want to create an out vector that consists of ones w...
Demirelief asked 28/12, 2015 at 15:41
1
© 2022 - 2025 — McMap. All rights reserved.