Skip to content

Tag: numpy

Insert a matrix in matplolib

I want to import a numpy matrix in a matplotlib plot. Let’s say that I have this matrix: In a scale from 0 to 3 of the x axis, I want to plot the points This is the code I use: and this is the outcome: Yet, if I have to use a large array of let’s say (1000×1000) elements

positive weights and negative weights [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I have an array named as weights – I am trying for hours to get an a…

Which numpy index is copy and which is view?

Question Regarding Numpy Indexing which can either return copy or view, please confirm if my understandings are correct. If not, please provide explanations and provide pointers to the related specifications. Q: Basic slicing The Numpy Indexing documentation has Basic Slicing and Indexing section. I believe t…

How to get the last index of model’s prediction?

I am new to PyTorch. I have a variable pred which has a list of a tensor. So I wanted to access the last element which is the class. I did that by first converting the list into a tensor. Now, how do I access the last element or is there any better/efficient way of doing this? EDIT: For further

How to use np.unique on big arrays?

I work with geospatial images in tif format. Thanks to the rasterio lib I can exploit these images as numpy arrays of dimension (nb_bands, x, y). Here I manipulate an image that contains patches of unique values that I would like to count. (they were generated with the scipy.ndimage.label function). My idea w…