Deep learning-study notes for index operations

1 Acknowledgements

Thanks for the information provided by netizens,

Original link: https://www.cnblogs.com/subic/p/8710946.html

2 Study notes for indexing in numpy

1.1 If you get the index of the maximum value of the np matrix

You can refer to the following sample code:

import numpy as np
matrix = np.array([[1, 2, 3],
              [4, 5, 6]])
index = np.unravel_index(matrix.argmax(), matrix.shape)
print(index)
>>>(1, 2)

 

Guess you like

Origin blog.csdn.net/songyuc/article/details/106712098