public void Serialize(IDataCombiner combiner)
        {
            ushort code;

            byte[] parameters;

            var attr = GetAttribute(combiner.GetType());

            if (!registered_functions_via_code.ContainsKey(attr.code | DATA_COMBINER_SIGN))
            {
                throw new ArgumentException(
                          nameof(combiner), "this type of IDataCombiner is not registered.");
            }
            var serializer = registered_functions_via_code[attr.code | DATA_COMBINER_SIGN];

            code       = serializer.Code;
            parameters = serializer.Serialize(combiner);
            if ((parameters?.Length ?? 0) != serializer.ParameterLength)
            {
                throw new Exception("invalid parameters' length.");
            }

            // serialaize type and parameters
            Serialize(code, parameters);
        }
        public NeuralNetworkInitializer SetDataCombiner(IDataCombiner combiner)
        {
            if (layers == null)
            {
                throw new Exception("The layers input is not set yet.");
            }

            if (combiner == null)
            {
                throw new ArgumentNullException(nameof(combiner));
            }
            combiners.Add(combiner);
            images.Add(CloseCurrentImage());

            return(this);
        }