Reputation: 621
I have initialized an array in the form of
for x in range(0,21000):
if np.amax(probability[x]) > 0.2:
i = i+1
Label = np.zeros(shape=(i,130))
and now with the following for cycle I would like to assign the value to each row of Label
for x in range(0,21000):
if np.amax(probability[x]) > 0.2:
Label[i] = [feature[x],y[x],np.amax(probability)[x]]
i = i+1
Where feature is an array 128*21000. Unfortunately, I keep receving the following error:
Label[i] = [feature[x],y[x],np.amax(probability)[x]]
IndexError: invalid index to scalar variable.
Upvotes: 1
Views: 1639
Reputation: 32197
You don't want a single scalar value for np.amax
but rather an array of values. Therefore you need to specify a specific axis for the call as follows:
np.amax(probability, axis=1)
You can see examples of the use of the axis
argument from the docs
Or if you really do want to use the scalar value, don't index it using [x]
in np.amax(probability)[x]
Upvotes: 1