Category "numpy-ndarray"

Build a image from multiple images

I have multiple images (more than 1000 / 288*288) with their respective coordinates (X,Y). All pictures put together should displayed a unique picture. However

numpy array custom dtype for the list of list

I am confusing in using custom dtype of numpy array which is converting the element of the list to be tuple. np.empty (1000, dtype = [('a',int), ('b','S4')]) t

How to make a vector of matrices in numpy

I would like to create a vector of the same matrix in numpy (so as an array). Let's say the matrix is: w = np.array([[1,2], [3,4], [

(Keras) ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type float)

I know this problem has been answered previously in the link below,but it does not apply to my situation.(Tensorflow - ValueError: Failed to convert a NumPy arr

how to calculate Manhattan distance (or L1/ cityblock) for two 2D array?

For 1D vector/array it's easier. For example: array1 = [1, 2, 3] array2 = [1, 1, 1] manhattan distance will be: (0+1+2) which is 3 import numpy as np def city

Python: appending numpy.array to list python overwrites the previous elements

I'm trying to plot a stellar orbit in a given potential. First, I initialize the position and velocity, and derive the acceleration from the position according

Efficiently get first N numbers that satisfy a condition in each row in a pytorch/numpy tensor

Given a tensor b, and I would like to extract N elements in each row that satisfy a specific condition. For example, suppose a is a matrix that indicates whethe

Is there something like np.linspace for 3D lines?

I have a 3x1 point vector representing the start point of some line, and a 3x1 point vector representing the end of some line. I would like to sample an arbitra

How to save a 'pos dictionary' type of object? (NetworkX)

I am using the networkx as nx. After creating a graph object (G), I use the data = nx.spring_layout(G) method to generate a dictionary (pos). Generating this po

How to add a new array to an existing npz file in a standard way?

I have a function which writes an array to a compressed *.npz file: def save_a(file): np.savez_compressed(file, a=[[1, 2, 3]]) I want to make a function

Convert n same-size, d-dimensional numpy arrays to a dataframe with d+n columns

I recently asked this question, about converting n 2-dimensional arrays to a dataframe with 2+n columns. The solution I got works perfectly well, but can not ea

How can I convert boolean values from np.diff() to the actual values

I have a numpy array of np.shape=(n,) I am attempting to iterate through each value of the array and subtract the 2nd value from the 1st, then see if the differ