.argmax and .max
时间: 2023-10-16 22:06:34 浏览: 41
These are two different functions in Python that can be used to find the maximum value of an array or list.
1. .argmax(): This function returns the index of the maximum value in an array or list.
Example:
```
import numpy as np
arr = np.array([4, 8, 1, 9, 5])
max_index = np.argmax(arr)
print(max_index) # Output: 3
```
In the above example, the .argmax() function returns the index 3, which corresponds to the maximum value in the array (9).
2. .max(): This function returns the maximum value in an array or list.
Example:
```
import numpy as np
arr = np.array([4, 8, 1, 9, 5])
max_value = np.max(arr)
print(max_value) # Output: 9
```
In the above example, the .max() function returns the maximum value in the array (9).