public static TensorIndices5 IndexOfMax <T>(this SpanTensor5 <T> tensor, IComparer <T> comparer = null)
            where T : unmanaged, IEquatable <T>
        {
            var span = tensor._Buffer;

            if (span.Length == 0)
            {
                return(TensorIndices5.Invalid);
            }

            if (comparer == null)
            {
                comparer = Comparer <T> .Default;
            }

            T   max = span[0];
            var idx = 0;

            for (int i = 1; i < span.Length; ++i)
            {
                var item = span[i];
                if (comparer.Compare(max, item) > 0)
                {
                    max = item; idx = i;
                }
            }

            return(tensor._Dimensions.GetDecomposedIndex(idx));
        }
        public static TensorIndices5 IndexOf <T>(this SpanTensor5 <T> tensor, T value)
            where T : unmanaged, IEquatable <T>
        {
            var idx = tensor._Buffer.IndexOf(value);

            if (idx < 0)
            {
                return(TensorSize5.Invalid);
            }
            return(tensor._Dimensions.GetDecomposedIndex(idx));
        }
        public static TensorIndices5 IndexOf <T>(this SpanTensor5 <T> tensor, Predicate <T> predicate)
            where T : unmanaged, IEquatable <T>
        {
            var span = tensor._Buffer;

            for (int i = 0; i < span.Length; ++i)
            {
                if (predicate(span[i]))
                {
                    return(tensor._Dimensions.GetDecomposedIndex(i));
                }
            }

            return(TensorIndices5.Invalid);
        }
 public static void ApplySoftMax(this SpanTensor5 <float> tensor)
 {
     SpanTensor.ApplySoftMax(tensor.Span);
 }