Exemplo n.º 1
0
        public Tensor Enhance(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D9x9(Temp, this.Data.Conv1_Weights, this.Data.Conv1_Biases);
            if (this.Step != null)
            {
                Step(5);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                Step(10);
            }
            Temp = Layers.BatchNorm(
                Temp,
                this.Data.Conv1_Shift,
                this.Data.Conv1_Scale,
                this.Data.Conv1_Mean,
                this.Data.Conv1_Var);
            if (this.Step != null)
            {
                Step(15);
            }
            Temp = Layers.ResidualBlock(
                Temp,
                this.Data.Res1_Conv1_Weights,
                this.Data.Res1_Conv2_Weights,
                this.Data.Res1_Conv1_Biases,
                this.Data.Res1_Conv2_Biases,
                this.Data.Res1_Conv1_Shift,
                this.Data.Res1_Conv2_Shift,
                this.Data.Res1_Conv1_Scale,
                this.Data.Res1_Conv2_Scale,
                this.Data.Res1_Conv1_Mean,
                this.Data.Res1_Conv2_Mean,
                this.Data.Res1_Conv1_Var,
                this.Data.Res1_Conv2_Var);
            if (this.Step != null)
            {
                Step(20);
            }
            Temp = Layers.ResidualBlock(
                Temp,
                this.Data.Res2_Conv1_Weights,
                this.Data.Res2_Conv2_Weights,
                this.Data.Res2_Conv1_Biases,
                this.Data.Res2_Conv2_Biases,
                this.Data.Res2_Conv1_Shift,
                this.Data.Res2_Conv2_Shift,
                this.Data.Res2_Conv1_Scale,
                this.Data.Res2_Conv2_Scale,
                this.Data.Res2_Conv1_Mean,
                this.Data.Res2_Conv2_Mean,
                this.Data.Res2_Conv1_Var,
                this.Data.Res2_Conv2_Var);
            if (this.Step != null)
            {
                Step(25);
            }
            Temp = Layers.ResidualBlock(
                Temp,
                this.Data.Res3_Conv1_Weights,
                this.Data.Res3_Conv2_Weights,
                this.Data.Res3_Conv1_Biases,
                this.Data.Res3_Conv2_Biases,
                this.Data.Res3_Conv1_Shift,
                this.Data.Res3_Conv2_Shift,
                this.Data.Res3_Conv1_Scale,
                this.Data.Res3_Conv2_Scale,
                this.Data.Res3_Conv1_Mean,
                this.Data.Res3_Conv2_Mean,
                this.Data.Res3_Conv1_Var,
                this.Data.Res3_Conv2_Var);
            if (this.Step != null)
            {
                Step(30);
            }
            Temp = Layers.ResidualBlock(
                Temp,
                this.Data.Res4_Conv1_Weights,
                this.Data.Res4_Conv2_Weights,
                this.Data.Res4_Conv1_Biases,
                this.Data.Res4_Conv2_Biases,
                this.Data.Res4_Conv1_Shift,
                this.Data.Res4_Conv2_Shift,
                this.Data.Res4_Conv1_Scale,
                this.Data.Res4_Conv2_Scale,
                this.Data.Res4_Conv1_Mean,
                this.Data.Res4_Conv2_Mean,
                this.Data.Res4_Conv1_Var,
                this.Data.Res4_Conv2_Var);
            if (this.Step != null)
            {
                Step(35);
            }
            Temp = Layers.ResidualBlock(
                Temp,
                this.Data.Res5_Conv1_Weights,
                this.Data.Res5_Conv2_Weights,
                this.Data.Res5_Conv1_Biases,
                this.Data.Res5_Conv2_Biases,
                this.Data.Res5_Conv1_Shift,
                this.Data.Res5_Conv2_Shift,
                this.Data.Res5_Conv1_Scale,
                this.Data.Res5_Conv2_Scale,
                this.Data.Res5_Conv1_Mean,
                this.Data.Res5_Conv2_Mean,
                this.Data.Res5_Conv1_Var,
                this.Data.Res5_Conv2_Var);
            if (this.Step != null)
            {
                Step(40);
            }
            Temp = Layers.ResidualBlock(
                Temp,
                this.Data.Res6_Conv1_Weights,
                this.Data.Res6_Conv2_Weights,
                this.Data.Res6_Conv1_Biases,
                this.Data.Res6_Conv2_Biases,
                this.Data.Res6_Conv1_Shift,
                this.Data.Res6_Conv2_Shift,
                this.Data.Res6_Conv1_Scale,
                this.Data.Res6_Conv2_Scale,
                this.Data.Res6_Conv1_Mean,
                this.Data.Res6_Conv2_Mean,
                this.Data.Res6_Conv1_Var,
                this.Data.Res6_Conv2_Var);
            if (this.Step != null)
            {
                Step(45);
            }
            Temp = Layers.Conv2DTranspose3x3(Temp, this.Data.Deconv1_Weights, this.Data.Deconv1_Biases);
            if (this.Step != null)
            {
                Step(50);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                Step(55);
            }
            Temp = Layers.BatchNorm(Temp, this.Data.Deconv1_Shift, this.Data.Deconv1_Scale, this.Data.Deconv1_Mean, this.Data.Deconv1_Var);
            if (this.Step != null)
            {
                Step(60);
            }
            Temp = Layers.Conv2DTranspose3x3(Temp, this.Data.Deconv2_Weights, this.Data.Deconv2_Biases);
            if (this.Step != null)
            {
                Step(65);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                Step(70);
            }
            Temp = Layers.BatchNorm(Temp, this.Data.Deconv2_Shift, this.Data.Deconv2_Scale, this.Data.Deconv2_Mean, this.Data.Deconv2_Var);
            if (this.Step != null)
            {
                Step(75);
            }
            Temp = Layers.Conv2DTranspose9x9(Temp, this.Data.Deconv3_Weights, this.Data.Deconv3_Biases);
            if (this.Step != null)
            {
                Step(80);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                Step(85);
            }
            Temp = Layers.BatchNorm(Temp, this.Data.Deconv3_Shift, this.Data.Deconv3_Scale, this.Data.Deconv3_Mean, this.Data.Deconv3_Var);
            if (this.Step != null)
            {
                Step(90);
            }
            Temp = Layers.Tanh(Temp);
            if (this.Step != null)
            {
                Step(95);
            }
            return(Temp);
        }
Exemplo n.º 2
0
        public Tensor Enhance(Tensor input)
        {
            var n = Layers.Conv2D3x3(input, Data.Conv1_Weights, Data.Conv1_Biases);

            n = Layers.ReLU(n);
            if (this.Step != null)
            {
                Step(2);
            }
            var temp = n;

            n = Layers.ResidualBlock(n, Data.Residual1);
            if (this.Step != null)
            {
                Step(7);
            }
            n = Layers.ResidualBlock(n, Data.Residual2);
            if (this.Step != null)
            {
                Step(12);
            }
            n = Layers.ResidualBlock(n, Data.Residual3);
            if (this.Step != null)
            {
                Step(17);
            }
            n = Layers.ResidualBlock(n, Data.Residual4);
            if (this.Step != null)
            {
                Step(22);
            }
            n = Layers.ResidualBlock(n, Data.Residual5);
            if (this.Step != null)
            {
                Step(27);
            }
            n = Layers.ResidualBlock(n, Data.Residual6);
            if (this.Step != null)
            {
                Step(32);
            }
            n = Layers.ResidualBlock(n, Data.Residual7);
            if (this.Step != null)
            {
                Step(37);
            }
            n = Layers.ResidualBlock(n, Data.Residual8);
            if (this.Step != null)
            {
                Step(42);
            }
            n = Layers.ResidualBlock(n, Data.Residual9);
            if (this.Step != null)
            {
                Step(47);
            }
            n = Layers.ResidualBlock(n, Data.Residual10);
            if (this.Step != null)
            {
                Step(52);
            }
            n = Layers.ResidualBlock(n, Data.Residual11);
            if (this.Step != null)
            {
                Step(57);
            }
            n = Layers.ResidualBlock(n, Data.Residual12);
            if (this.Step != null)
            {
                Step(62);
            }
            n = Layers.ResidualBlock(n, Data.Residual13);
            if (this.Step != null)
            {
                Step(67);
            }
            n = Layers.ResidualBlock(n, Data.Residual14);
            if (this.Step != null)
            {
                Step(72);
            }
            n = Layers.ResidualBlock(n, Data.Residual15);
            if (this.Step != null)
            {
                Step(77);
            }
            n = Layers.ResidualBlock(n, Data.Residual16);
            if (this.Step != null)
            {
                Step(82);
            }
            n = Layers.Conv2D3x3(n, Data.Conv2_Weights, new Tensor(1, 1, 64));
            n = Layers.BatchNorm(n, Data.Conv2_Mean, Data.Conv2_Variance, Data.Conv2_Shift, Data.Conv2_Scale);
            n = Layers.Elementwise(n, temp);
            if (this.Step != null)
            {
                Step(87);
            }
            n = Layers.Conv2D3x3(n, Data.Conv3_Weights, Data.Conv3_Biases);
            n = Layers.SubpixelConv2D(n);
            n = Layers.ReLU(n);
            if (this.Step != null)
            {
                Step(92);
            }
            n = Layers.Conv2D3x3(n, Data.Conv4_Weights, Data.Conv4_Biases);
            n = Layers.SubpixelConv2D(n);
            n = Layers.ReLU(n);
            if (this.Step != null)
            {
                Step(97);
            }
            n = Layers.Conv2D1x1(n, Data.Conv5_Weights, Data.Conv5_Biases);
            n = Layers.Tanh(n);
            if (this.Step != null)
            {
                Step(100);
            }
            return(n);
        }
        public Tensor Enhance(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_Weights, this.Data.Conv1_Biases);
            if (this.Step != null)
            {
                Step(7);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(14);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_Weights, this.Data.Conv2_Biases);
            if (this.Step != null)
            {
                Step(21);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(28);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_Weights, this.Data.Conv3_Biases);
            if (this.Step != null)
            {
                Step(35);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(42);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_Weights, this.Data.Conv4_Biases);
            if (this.Step != null)
            {
                Step(49);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(56);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv5_Weights, this.Data.Conv5_Biases);
            if (this.Step != null)
            {
                Step(63);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(70);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv6_Weights, this.Data.Conv6_Biases);
            if (this.Step != null)
            {
                Step(77);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(84);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv7_Weights, this.Data.Conv7_Biases);
            if (this.Step != null)
            {
                Step(91);
            }
            Temp = Layers.LeakyReLU(Temp);
            if (this.Step != null)
            {
                Step(98);
            }
            return(Temp);
        }