コード例 #1
0
        /// <summary>
        /// Return the numeric (double) based training parameter.
        /// </summary>
        /// <param name="key">Specifies the key of the value to get.</param>
        /// <returns>The double based value is returned.</returns>
        public double GetTrainingParameter(OrtTrainingNumericParameter key)
        {
            string str       = null;
            var    allocator = OrtAllocator.DefaultInstance;
            IntPtr valHandle = IntPtr.Zero;

            NativeApiStatus.VerifySuccess(NativeMethodsTraining.OrtGetNumericParameter(_nativeHandle, key, allocator.Pointer, out valHandle));

            using (var ortAllocation = new OrtMemoryAllocation(allocator, valHandle, 0))
            {
                str = NativeOnnxValueHelper.StringFromNativeUtf8(valHandle);
            }
            return(double.Parse(str));
        }
コード例 #2
0
 /// <summary>
 /// Set the numeric (double) based training parameters.
 /// </summary>
 /// <param name="key">Specifies the key of the value to set.</param>
 /// <param name="dfVal">Specifies the value to be set.</param>
 public void SetTrainingParameter(OrtTrainingNumericParameter key, double dfVal)
 {
     NativeApiStatus.VerifySuccess(NativeMethodsTraining.OrtSetNumericParameter(_nativeHandle, key, dfVal));
 }