numpy-ufunc

np.argsort() implementation is not found

np.argsort() implementation is not found Question: I would like to see how numpy.argsort() works. In the documentation, the source for numpy.argsort() is numpy.core.fromnumeric.py. This is understandable. https://numpy.org/doc/stable/reference/generated/numpy.argsort.html core.fromnumeric.argsort() is a bit more complicated. Ignoring decorators, if fromnumeric.argsort(arr) returns _wrapfunc(arr, "argsort"), which returns arr.argsort(). This is not a problem. Assuming arr is numpy.ndarray, it might be …

Total answers: 1

Numpy, multiply array with scalar

Numpy, multiply array with scalar Question: 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? For example: a_1 = np.array([1.0, 2.0, 3.0]) a_2 = np.array([[1., 2.], [3., 4.]]) b = 2.0 Expected result: …

Total answers: 2

Equivalent for np.add.at in tensorflow

Equivalent for np.add.at in tensorflow Question: 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 Asked By: Amey Agrawal || Source Answers: For np.add.at, you probably want to look at tf.SparseTensor, which represents a tensor by a list …

Total answers: 3

Numpy passing input array as `out` argument to ufunc

Numpy passing input array as `out` argument to ufunc Question: 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: >>> import numpy as np >>> arr = np.array([1.2, 3.4, 4.5]) >>> …

Total answers: 2