Understanding argmax

前端 未结 4 682
生来不讨喜
生来不讨喜 2020-12-24 13:49

Let say I have the matrix

import numpy as np    
A = np.matrix([[1,2,3,33],[4,5,6,66],[7,8,9,99]])

I am trying to understand the function a

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 14:24

    argmax is a function which gives the index of the greatest number in the given row or column and the row or column can be decided using axis attribute of argmax funcion. If we give axis=0 then it will give the index from columns and if we give axis=1 then it will give the index from rows.

    In your given example A[1:, 2] it will first fetch the values from 1st row on wards and the only 2nd column value from those rows, then it will find the index of max value from into the resulted matrix.

提交回复
热议问题