////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes a new instance of the Autoencoders.AutoencoderWeights class.
        /// </summary>
        ///
        /// <param name="PNumLayers">       Number of layers. </param>
        /// <param name="PLayers">          The layers. </param>
        /// <param name="PWInitializer">    The password initializer. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public AutoencoderWeights(int PNumLayers, RestrictedBoltzmannMachineLayer[] PLayers, IWeightInitializer PWInitializer)
        {
            numweightsets = PNumLayers - 1;
            weights       = new RestrictedBoltzmannMachineWeightSet[numweightsets];
            for (int i = 0; i < numweightsets; i++)
            {
                weights[i] = new RestrictedBoltzmannMachineWeightSet(PLayers[i].Count, PLayers[i + 1].Count, PWInitializer);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Loads the given p file. </summary>
        ///
        /// <param name="PFile">    The file to load. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        internal void Load(TextReader PFile)
        {
            numweightsets = int.Parse(PFile?.ReadLine());
            weights       = new RestrictedBoltzmannMachineWeightSet[numweightsets];
            for (int i = 0; i < numweightsets; i++)
            {
                weights[i] = RestrictedBoltzmannMachineWeightSet.Load(PFile);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Creates a new object that is a copy of the current instance. </summary>
        ///
        /// <returns>   A new object that is a copy of this instance. </returns>
        ///
        /// <seealso cref="M:System.ICloneable.Clone()"/>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public object Clone()
        {
            RestrictedBoltzmannMachineWeightSet newweights = new RestrictedBoltzmannMachineWeightSet(preSize, postSize, new ZeroWeightInitializer());

            for (int i = 0; i < preSize; i++)
            {
                for (int j = 0; j < postSize; j++)
                {
                    newweights.SetWeight(i, j, weights[i][j]);
                }
            }
            return(newweights);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Loads the given p file. </summary>
        ///
        /// <param name="PFile">    The file to load. </param>
        ///
        /// <returns>   A RestrictedBoltzmannMachineWeightSet. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        internal static RestrictedBoltzmannMachineWeightSet Load(TextReader PFile)
        {
            RestrictedBoltzmannMachineWeightSet retval = new RestrictedBoltzmannMachineWeightSet
            {
                preSize = int.Parse(PFile.ReadLine())
            };

            retval.weights       = new double[retval.preSize][];
            retval.weightChanges = new double[retval.preSize][];
            for (int i = 0; i < retval.preSize; i++)
            {
                retval.weights[i] = Utility.LoadArray(PFile);
            }
            retval.postSize = retval.weights[0].GetLength(0);
            for (int i = 0; i < retval.preSize; i++)
            {
                retval.weightChanges[i] = new double[retval.postSize];
            }
            return(retval);
        }