1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
package tensor
import "github.com/pkg/errors"
/* Argmax */
// Argmax finds the index of the max value along the axis provided
func (t *Dense) Argmax(axis int) (retVal *Dense, err error) {
e := t.e
switch am := e.(type) {
case denseArgmaxer:
return am.argmaxDenseTensor(t, axis)
case Argmaxer:
var ret Tensor
var ok bool
if ret, err = am.Argmax(t, axis); err != nil {
return nil, errors.Wrapf(err, opFail, "Argmax")
}
if retVal, ok = ret.(*Dense); !ok {
return nil, errors.Errorf(extractionFail, "*Dense", ret)
}
return
}
return nil, errors.New("Engine does not suport Argmax")
}
/* Argmin */
// Argmin finds the index of the min value along the axis provided
func (t *Dense) Argmin(axis int) (retVal *Dense, err error) {
e := t.e
switch am := e.(type) {
case denseArgminer:
return am.argminDenseTensor(t, axis)
case Argminer:
var ret Tensor
var ok bool
if ret, err = am.Argmin(t, axis); err != nil {
return nil, errors.Wrapf(err, opFail, "Argmax")
}
if retVal, ok = ret.(*Dense); !ok {
return nil, errors.Errorf(extractionFail, "*Dense", ret)
}
return
}
return nil, errors.New("Engine does not suport Argmax")
}
|