scalar

Multiply different size nested array with scalar

Multiply different size nested array with scalar Question: In my python code, I have an array that has different size inside like this arr = [ [1], [2,3], [4], [5,6,7], [8], [9,10,11] ] I want to multiply them by 10 so it will be like this arr = [ [10], [20,30], [40], [50,60,70], [80], [90,100,110] …

Total answers: 2

How to multiply a tensor row-wise by a vector in PyTorch?

How to multiply a tensor row-wise by a vector in PyTorch? Question: When I have a tensor m of shape [12, 10] and a vector s of scalars with shape [12], how can I multiply each row of m with the corresponding scalar in s? Asked By: Chris || Source Answers: You need to add …

Total answers: 4

How to multiply all integers inside list

How to multiply all integers inside list Question: Hello so I want to multiply the integers inside a list. For example; l = [1, 2, 3] l = [1*2, 2*2, 3*2] output: l = [2, 4, 6] So I was searching online and most of the answers were regarding multiply all the integers with each …

Total answers: 6

python: how to identify if a variable is an array or a scalar

python: how to identify if a variable is an array or a scalar Question: I have a function that takes the argument NBins. I want to make a call to this function with a scalar 50 or an array [0, 10, 20, 30]. How can I identify within the function, what the length of NBins …

Total answers: 14

Python RuntimeWarning: overflow encountered in long scalars

Python RuntimeWarning: overflow encountered in long scalars Question: I am new to programming. In my latest Python 2.7 project I encountered the following: RuntimeWarning: overflow encountered in long_scalars Could someone please elaborate what this means and what I could do to fix that? The code runs through, but I’m not sure if it is a …

Total answers: 2