Category "numpy"

How to extract tensors to numpy arrays or lists from a larger pytorch tensor

I have a list of pytorch tensors as shown below: data = [[tensor([0, 0, 0]), tensor([1, 2, 3])], [tensor([0, 0, 0]), tensor([4, 5, 6])]] Now this is ju

Using tf.data.Dataset as training input to Keras model NOT working

I have a simple code, which DOES work, for training a Keras model in Tensorflow using numpy arrays as features and labels. If I then wrap these numpy arrays usi

AttributeError: 'float' object has no attribute 'dtype'

When I try to use a custom activation function in keras (2.2.5), I create a new activation function gelu. add it in activations.py : from . import backend as K

ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1,

I've got this error: ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has s

add negative seconds using numpy date time

I'm trying to add an array of time offsets (in seconds, which can be both positive and negative) to a constant timestamp using numpy. numpy version is 1.19.1, p

NumPy Interpolate Between Two 2-D Arrays At Various Timesteps

I have a pair of two-dimensional arrays from a gridded dataset (in GeoTIFF format), both with the exact same resolution and number of rows/columns. Suppose Arra

get maximum of absolute along axis

I have a couple of ndarrays with same shape, and I would like to get one array (of same shape) with the maximum of the absolute values for each element. So I de

How to convert cv2.rectangle bounding box to YoloV4 annotation format (relative x,y,w,h)?

I have trained a Yolo4 network and it is giving me bounding boxes as: img_array = cv2.cvtColor(cv2.imread('image.png'), cv2.COLOR_BGR2RGB) classes, scores, bbox

Numpy 1.11 doesn't install in virtualenv @ Ubuntu Studio

I have Python 3 virtualenv set up @ 4.15.0-23-lowlatency #25-Ubuntu. Inside virtualenv I have numpy1.14 installed. I want to install numpy1.11. I get the error:

How to control the display precision of a NumPy float64 scalar?

I'm writing a teaching document that uses lots of examples of Python code and includes the resulting numeric output. I'm working from inside IPython and a lot

RuntimeError: 1D target tensor expected, multi-target not supported Python: NumPy

I am dealing with a CNN and I get the following error on the line loss = criterion(outputs, data_y): Here is the relevant code snippet: def run(model, X_train,

Cannot uninstall numpy,

I'm trying to use pip to uninstall numpy(I also installed pandas, but I seem to have been able to uninstall that). In the case of `numpy, I get the following ou

Create new numpy array by duplicating each item in an array

I would like to create a new numpy array by repeating each item in another array by a given number of times (n). I am currently doing this with a for loop and .

numpy and cv2, no modules available after installation via pip on linux

I installed opencv and numpy using pip on debian 11.2 with python 3.9. In visual studio the modules aren't available and terminal returns: Traceback (most recen

NumPy adds a dot after each element of an array which I can’t strip

I am trying to write code which generates a sound file based on a series of frequencies I give it, but I have reached a point where compiling the arrays of inte

Initializing a class with numpy array question

So I have defined the following function to be entered into a class: MatrixConverter(arr) Which works exactly how I want it to, taking in a numpy array as argu

Difference between cupy.asnumpy() and get()

Given a CuPy array a, there are two ways to get a numpy array from it: a.get() and cupy.asnumpy(a). Is there any practical difference between them? import cupy

Decypher AIFF File Contents with Python, AIFC

I am trying to extract values of an AIFF sound file to do some processing (FFT, frequency content, filter modeling, etc.). I have used AIFC to extract the para

TypeError: lowerb is not a numpy array, neither a scalar

I needed to run some parts of the code in GPU using cupy instead of numpy. So, I only made comment out for this line # import numpy as np and used this line ins

Decypher AIFF File Contents with Python, AIFC

I am trying to extract values of an AIFF sound file to do some processing (FFT, frequency content, filter modeling, etc.). I have used AIFC to extract the para