Questions tagged [elementwise-operations]

204 questions
0
votes
0 answers

Elementwise vector Multiplication in cublas

Is there elementwise multiplication in cublas? I am trying to perform these Matlab operations x .* s x ./ s I have on host implementation using for loop and another CUDA one, but I wonder if I missed cublas library function that can do it in an…
Karam Abo Ghalieh
  • 428
  • 1
  • 5
  • 19
0
votes
2 answers

tensorflow two matrix elementwise multiply in axis = 0, (M,k) * (M,l) --> (M,k*l)

I have a two matrix, F(shape = (4000, 64)) and M(shape=(4000,9)) and want to have result that have shape = (4000,64*9) i can think with for loop with below code(ideal) result = np.zeros(4000,64*9) ind = 0 for i in range(64): for j in range(9): …
minssi
  • 333
  • 1
  • 2
  • 10
0
votes
1 answer

Python: element-wise comparison of array to non-array

I'm trying to plot some complex functions using numpy. Example of some working code: import numpy as np from PIL import Image size = 1000 w = np.linspace(-10, 10, size) x, y = np.meshgrid(w, w) r = x + 1j*y def f(q): return np.angle(q) z =…
dain
  • 672
  • 1
  • 7
  • 22
0
votes
1 answer

Element-wise Multiplication of (x,y,1) * (x,y)

matrixADimensions = matrixA.shape # returns [901,1249,1] matrixBDimensions = matrixB.shape # returns [901,1249] I am trying to get the element-wise multiplication of matrixA and matrixB but I am getting the error ValueError: operands could not be…
0
votes
1 answer

How to multiply each column of a matrix by a vector element-wise in Theano?

I have a Theano dvector with 100 elements. I also have a matrix with 5 columns and 100 rows (in other words each column contains 100 elements). Now I need to apply an element-wise multiplication of each column by the vector. What is a correct way to…
Roman
  • 124,451
  • 167
  • 349
  • 456
0
votes
2 answers

Round only numeric elements in cell array with different data types

I have a cell with different types of variables (double & strings), I want to round the numeric elements in the cell. round function can work only with arrays and not with cells, so I'm trying to use cell2mat - but this function can't be used in…
0
votes
2 answers

Elementwise product between a vector and a matrix using GNU Blas subroutines

I am working on C, using GNU library for scientific computing. Essentially, I need to do the equivalent of the following MATLAB code: x=x.*(A*x); where x is a gsl_vector, and A is a gsl_matrix. I managed to do (A*x) with the following…
TheRevanchist
  • 331
  • 1
  • 4
  • 12
0
votes
1 answer

elementwise square of theano matrix

I have a theano covariance matrix, and i am trying to calculate element wise square of it. I have written following code for same: import theano a, b = theano.tensor.matrices('a', 'b') square = theano.function([a, b], a * b) sq =…
Shweta
  • 1,111
  • 3
  • 15
  • 30
0
votes
1 answer

How to do elementwise processing (first int, then pairwise absolute length) to avoid memory problems? (python)

I want to process a big list of uint numbers (test1) and I do that i chunks of "length". I need them as signed int and then I need it as absolute length from each pait of even and odd values in this list. But I want to get rid of two problems: it…
Andreas Hornig
  • 2,439
  • 5
  • 28
  • 36
0
votes
1 answer

Performing calculations on only certain columns in a matrix in SAS IML

I need to create, in IML, a matrix with several columns and do some calculations on only some columns (the values in one column must not change). For example, I'll need to multiply one column by another elementwise. What is the syntax for this?
Mhoram
  • 421
  • 2
  • 6
  • 13
0
votes
1 answer

Element wise multiplication of a 3D matrix by a 2D matrix

Consider the following 2 matrices: A = 3x3x3 and B = 3x3. Is it possible to perform an element wise multiplication between each slice of A and the kernel B without using a for loop? My current implementation is as follows: for i = 1:3 C =…
Jeremy Borg
  • 413
  • 2
  • 6
  • 16
0
votes
2 answers

Comparing numpy arrays containing strings

I am looking for an efficient way to check whether all string entries in a certain numpy array are contained in a second numpy array. See the example below. Array_1 would be the minimal animals that should be checked for. The function should return…
cattt84
  • 941
  • 1
  • 10
  • 17
0
votes
2 answers

OR element wise operation over two binary lists

I have the following code of two binary lists and I want to obtain a resulting list in which the element i will be the OR operation applied to the i elements of the two lists: from operator import ior l_0 = [01100] l_1 = [11000] print map(ior,…
jchanger
  • 739
  • 10
  • 29
0
votes
3 answers

Greater of two numpy arrays, element-wise

I have two numpy arrays and I'm trying to find the greater of them (element wise, i.e. all elements should be greater) import numpy as np a = np.array([4,5,6]) b = np.array([7,8,9]) if b > a: print 'True' But I'm not getting the desired…
HVN19
  • 49
  • 1
  • 6
-1
votes
2 answers

Python Neural Networks. ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I am trying to add a ReLU activation function layer to my neural network. However when I try the following code I get this error: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() I tried…
1 2 3
13
14