I'm trying to index a 2D array with another 2D array which works fine in Numpy, but I want to use it in a function decorated with Numba's njit decorator, which gives me this error:
TypingError: No implementation of function Function(
I have to np.arrays which I need to join in a really weird manner. Unfortunately the shapes are givn, I can neither change output nor input.
frequencies =
[100. 200.] (2,)
and
values =
[[1. 2.]
[3. 4.]
[5. 6.]
[7. 8.]] (4, 2)
The required…
I am in a position to extract whole data from an array. The simplest method would be simply passing array[:]. However, I want to make it automated as part of the larger project where the index would be varying with the data format. Therefore, is it…
Let's say we have a
n*n matrix A
m*m matrix B
a vector b=[b_1,...,b_m] of block sizes with b_1 + ... + b_m = n and b_i >= 1.
Then I define a n*n block matrix B_block whose (i,j)-th block is a b_i*b_j matrix of constant value B_{ij}. How can I…
I am trying to extract several values at once from an array but I can't seem to find a way to do it in a one-liner in Numpy.
Simply put, considering an array:
a = numpy.arange(10)
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
I would like to be able to…
# split into inputs and outputs
X, y = data[:, :-1], data[:, -1]
print(X.shape, y.shape)
Can someone explain the second line of code with reference to specific documentation? I know its slicing but the I couldn't find any reference for the…
I have data array with unknown shape and array bounds of bounds for slicing data. This code is for 3D data, but is there any way of generalizing this to N-dim?
for b in bounds:
l0, u0 = b[0]
l1, u1 = b[1]
l2, u2 = b[2]
a =…
I have been searching if there is an standard mehtod to create a subarray using relative indexes. Take the following array into consideration:
>>> m = np.arange(25).reshape([5, 5])
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
…
I have a matrix A of zise MxN, and vector b of size L.
how can I create a matrix C of size MxNxL such that:
C[m, n, k] = A[m, n] * b[k]
pretty much the same as dot product of two vectors to create 2D matrix, but with one dimention higher.
I had…
How can I slice a 3D tensor using a 1D tensor? For instance, consider the following 2 tensors: t of size [Batch, Sequence, Dim]; and idx of size [Batch]. The values of idx are restricted to be integers between 0 and Sequence-1.
I need tensor idx to…
If I have a large 2D numpy array and 2 arrays which correspond to the x and y indices I want to extract, It's easy enough:
h = np.arange(49).reshape(7,7)
# h = [[0, 1, 2, 3, 4, 5, 6],
# [7, 8, 9, 10, 11, 12, 13],
# [14, 15, 16, 17, 18, 19,…
I have a NumPy array of dimension 698x64x64 (64rows, 64columns)
I would like to slice it into a new array of 698x32x32 by taking every second row and column of the original array. How do I do that?
I have a pandas dataframe which has more than 5 millions rows. I try to slice it (time series to supervised frame) by using the function below. However it consumes too much ram and collaps during long sequences (look_back, forecast_horizon). As I…