Linked Questions

14 votes
2 answers
13k views

I am not sure about the difference between (N,) and (N,1) in numpy. Assuming both are some features, they have same N dimension, and both have one sample. What's the difference? a = np.ones((10,)) ...
jef's user avatar
  • 4,093
6 votes
2 answers
15k views

I noticed that for a rank 1 array with 3 elements numpy returns (3,) for the shape. I know that this tuple represents the size of the array along each dimension, but why isn't it (3,1)? import numpy ...
Alaa Awad's user avatar
  • 4,282
5 votes
3 answers
9k views

I've recently encountered a couple of bugs due to numpy arrays being in the shape (x,) - these can easily be fixed by the snippet below a = np.array([1,2,3,4]) #this form produced a bug a.shape >&...
draco_alpine's user avatar
3 votes
2 answers
4k views

I find that I often have to reshape (5,) into (5,1) in order to use dot product. What can't I just use a dot product with a vector of shape (5,)?
kwotsin's user avatar
  • 2,933
1 vote
2 answers
10k views

I have an array converted from list, when I try to get its shape, I got only one number. like this: list1=[1,2,3,4,5] a1=numpy.array(list1) print a1.shape and I got (5,) and then I ...
YD Han's user avatar
  • 75
7 votes
1 answer
6k views

I have been curious about this for some time. I can live with that, but it always bites me when enough care is not taken, so I decide to post it here. Suppose the following example (Numpy version = 1....
Taozi's user avatar
  • 373
4 votes
1 answer
2k views

What is the difference between numpy.zeros(n) and numpy.zeros(n,1)? The output for the first statement is [0 0 ..... n times] whereas the second one is ([0] [0] .... n rows)
Apratim Bhattacharya's user avatar
0 votes
1 answer
841 views

I have this NumPy array: X = numpy.linspace(1, 10, 10) I believe the output will become (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) Why is the shape of this array (10,)? I don't understand why it isn't (1,10).
Jake's user avatar
  • 19
0 votes
1 answer
588 views

I'm using train_test_split with my dataframe, my code looks something like this: df = pd.read_csv('data.csv', header=None) y = df[0] X_train, X_test, y_train, y_test = train_test_split(df, y,...
jj2593's user avatar
  • 77
0 votes
1 answer
312 views

What is the difference between train_x = np.asarray([[0.0], [1.0], [2.0], [3.0], [4.0]]) train_y = np.asarray([1.0, 1.1, 3.0, 2.0, 5.0]) in Python numpy.asarray assignment? What is the meaning of [] ...
user avatar
0 votes
0 answers
66 views

These two seem both array to me. # suppose that test_data has [1000,728] shape print (test_data[0:1,:].shape) # output [1,728] print (test_data[0,:].shape) # output [728,] I tried these two arrays ...
captainst's user avatar
  • 657
1 vote
1 answer
57 views

What does this mean in numpy coding, (4,)? You have an array and you run the shape of it and it gives you this answer. What does it mean? x = np.array([1, 2, 3, 4]) x.shape (4,)
german's user avatar
  • 53
0 votes
0 answers
31 views

What is the difference between numpy arrays with shapes of form (n,) and (n,1), where n is some number (like 150)? For example, x_dat = np.random.normal(size=150) returns an array of shape (150,), ...
algebroo's user avatar
  • 132
0 votes
0 answers
30 views

What does (13, ) mean here? without column?
Leon's user avatar
  • 112
0 votes
0 answers
30 views

In Numpy, what is the difference between an array with shape (4,) and an array with shape (4,1)? Is it that the latter is a vector?
stochasticmrfox's user avatar

15 30 50 per page