Esempio n. 1
0
        public static void Serialize(LossMetric net, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException();
            }

            net.ThrowIfDisposed();

            var str   = Dlib.Encoding.GetBytes(path);
            var error = NativeMethods.LossMetric_serialize(net.NetworkType, net.NativePtr, str, str.Length, out var errorMessage);

            switch (error)
            {
            case NativeMethods.ErrorType.DnnNotSupportNetworkType:
                throw new NotSupportNetworkTypeException(net.NetworkType);

            case NativeMethods.ErrorType.GeneralSerialization:
                throw new SerializationException(StringHelper.FromStdString(errorMessage, true));
            }
        }
Esempio n. 2
0
            internal LossDetails(LossMetric parent, IntPtr ptr)
                : base(false)
            {
                if (parent == null)
                {
                    throw new ArgumentNullException(nameof(parent));
                }

                parent.ThrowIfDisposed();

                this._Parent   = parent;
                this.NativePtr = ptr;
            }
Esempio n. 3
0
            internal Subnet(LossMetric parent)
            {
                if (parent == null)
                {
                    throw new ArgumentNullException(nameof(parent));
                }

                parent.ThrowIfDisposed();

                this._Parent = parent;

                var err = Native.loss_metric_subnet(parent.NativePtr, parent.NetworkType, out var ret);

                this.NativePtr = ret;
            }
Esempio n. 4
0
        public static void Serialize(LossMetric net, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException();
            }

            net.ThrowIfDisposed();

            var str = Encoding.UTF8.GetBytes(path);

            Native.loss_metric_serialize(net.NativePtr, net.NetworkType, str);
        }
Esempio n. 5
0
        public static void Serialize(ProxySerialize serialize, LossMetric net)
        {
            if (serialize == null)
            {
                throw new ArgumentNullException(nameof(serialize));
            }
            if (net == null)
            {
                throw new ArgumentNullException(nameof(net));
            }

            net.ThrowIfDisposed();

            var error = NativeMethods.LossMetric_serialize_proxy(net.NetworkType, serialize.NativePtr, net.NativePtr, out var errorMessage);

            switch (error)
            {
            case NativeMethods.ErrorType.DnnNotSupportNetworkType:
                throw new NotSupportNetworkTypeException(net.NetworkType);

            case NativeMethods.ErrorType.GeneralSerialization:
                throw new SerializationException(StringHelper.FromStdString(errorMessage, true));
            }
        }