public BackPropNetwork(NetworkProperties props, BackPropProperties backProps, Random rnd)
        {
            this.rnd       = rnd; // for Shuffle()
            this.backProps = backProps;

            this.Network = new NeuralNetwork(props, rnd);

            // back-prop related arrays below
            this.hGrads = new double[props.NumHidden];
            this.oGrads = new double[props.NumOutput];

            this.ihPrevWeightsDelta = NetworkData.MakeMatrix(props.NumInput, props.NumHidden);
            this.hPrevBiasesDelta   = new double[props.NumHidden];
            this.hoPrevWeightsDelta = NetworkData.MakeMatrix(props.NumHidden, props.NumOutput);
            this.oPrevBiasesDelta   = new double[props.NumOutput];
        }
Пример #2
0
        public NetworkData Clone()
        {
            var ret = new NetworkData(this.Props);

            Buffer.BlockCopy(this.hBiases, 0, ret.hBiases, 0, Buffer.ByteLength(this.hBiases));
            Buffer.BlockCopy(this.oBiases, 0, ret.oBiases, 0, Buffer.ByteLength(this.oBiases));

            for (int i = 0; i < this.ihWeights.Length; i++)
            {
                Buffer.BlockCopy(this.ihWeights[i], 0, ret.ihWeights[i], 0, Buffer.ByteLength(this.ihWeights[0]));
            }

            for (int i = 0; i < this.hoWeights.Length; i++)
            {
                Buffer.BlockCopy(this.hoWeights[i], 0, ret.hoWeights[i], 0, Buffer.ByteLength(this.hoWeights[0]));
            }
            return ret;
        }
Пример #3
0
        public NetworkData Clone()
        {
            var ret = new NetworkData(this.Props);

            Buffer.BlockCopy(this.hBiases, 0, ret.hBiases, 0, Buffer.ByteLength(this.hBiases));
            Buffer.BlockCopy(this.oBiases, 0, ret.oBiases, 0, Buffer.ByteLength(this.oBiases));

            for (int i = 0; i < this.ihWeights.Length; i++)
            {
                Buffer.BlockCopy(this.ihWeights[i], 0, ret.ihWeights[i], 0, Buffer.ByteLength(this.ihWeights[0]));
            }

            for (int i = 0; i < this.hoWeights.Length; i++)
            {
                Buffer.BlockCopy(this.hoWeights[i], 0, ret.hoWeights[i], 0, Buffer.ByteLength(this.hoWeights[0]));
            }
            return(ret);
        }
Пример #4
0
        public bool IsEqual(NetworkData other)
        {
            if (this.Props.NumInput != other.Props.NumInput)
            {
                return(false);
            }
            if (this.Props.NumHidden != other.Props.NumHidden)
            {
                return(false);
            }
            if (this.Props.NumOutput != other.Props.NumOutput)
            {
                return(false);
            }

            if (!this.hBiases.SequenceEqual(other.hBiases))
            {
                return(false);
            }
            if (!this.oBiases.SequenceEqual(other.oBiases))
            {
                return(false);
            }

            for (var i = 0; i < this.ihWeights.Length; i++)
            {
                if (!this.ihWeights[i].SequenceEqual(other.ihWeights[i]))
                {
                    return(false);
                }
            }
            for (var i = 0; i < this.hoWeights.Length; i++)
            {
                if (!this.hoWeights[i].SequenceEqual(other.hoWeights[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #5
0
 private NeuralNetwork(NetworkData data)
 {
     this.Data = data;
 }
Пример #6
0
 private NeuralNetwork(NetworkData data)
 {
     this.Data = data;
 }
Пример #7
0
        public bool IsEqual(NetworkData other)
        {
            if (this.Props.NumInput != other.Props.NumInput) return false;
            if (this.Props.NumHidden != other.Props.NumHidden) return false;
            if (this.Props.NumOutput != other.Props.NumOutput) return false;

            if (!this.hBiases.SequenceEqual(other.hBiases)) return false;
            if (!this.oBiases.SequenceEqual(other.oBiases)) return false;

            for (var i = 0; i < this.ihWeights.Length; i++)
            {
                if (!this.ihWeights[i].SequenceEqual(other.ihWeights[i])) return false;
            }
            for (var i = 0; i < this.hoWeights.Length; i++)
            {
                if (!this.hoWeights[i].SequenceEqual(other.hoWeights[i])) return false;
            }
            return true;
        }