///<summary>Выполняет прямой проход через кодирующую нейросеть.</summary>
        ///<param name="Content4_1">Контент со слоя ReLU4_1.</param>
        ///<param name="Style4_1">Стиль со слоя ReLU4_1.</param>
        ///<param name="Content5_1">Контент со слоя ReLU5_1.</param>
        ///<param name="Style5_1">Стиль со слоя ReLU5_1.</param>
        public Tensor Stylize(Tensor Content4_1, Tensor Style4_1, Tensor Content5_1, Tensor Style5_1)
        {
            var Fc4_1 = Layers.Norm(Content4_1);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var Fs4_1 = Layers.Norm(Style4_1);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }

            var Fc5_1 = Layers.Norm(Content5_1);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var Fs5_1 = Layers.Norm(Style5_1);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }

            var f4_1 = Layers.Conv2D1x1(Fc4_1, this.Data.sanet4_1_f_Weights, this.Data.sanet4_1_f_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var g4_1 = Layers.Conv2D1x1(Fs4_1, this.Data.sanet4_1_g_Weights, this.Data.sanet4_1_g_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var h4_1 = Layers.Conv2D1x1(Style4_1, this.Data.sanet4_1_h_Weights, this.Data.sanet4_1_h_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }

            var f5_1 = Layers.Conv2D1x1(Fc5_1, this.Data.sanet5_1_f_Weights, this.Data.sanet5_1_f_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var g5_1 = Layers.Conv2D1x1(Fs5_1, this.Data.sanet5_1_g_Weights, this.Data.sanet5_1_g_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var h5_1 = Layers.Conv2D1x1(Style5_1, this.Data.sanet5_1_h_Weights, this.Data.sanet5_1_h_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }

            var S4_1 = Tensor.MatMul(f4_1.Flat().Transpose(), g4_1.Flat());

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            S4_1 = Layers.Softmax(S4_1);
            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var O4_1 = Layers.ElementwiseSum(Layers.Conv2D1x1(Tensor.MatMul(h4_1.Flat(), S4_1.Transpose()).Unflat(Content4_1.Width, Content4_1.Height), this.Data.sanet4_1_out_conv_Weights, this.Data.sanet4_1_out_conv_Biases), Content4_1);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }

            var S5_1 = Tensor.MatMul(f5_1.Flat().Transpose(), g5_1.Flat());

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            S5_1 = Layers.Softmax(S5_1);
            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            var O5_1 = Layers.ElementwiseSum(Layers.Conv2D1x1(Tensor.MatMul(h5_1.Flat(), S5_1.Transpose()).Unflat(Content5_1.Width, Content5_1.Height), this.Data.sanet5_1_out_conv_Weights, this.Data.sanet5_1_out_conv_Biases), Content5_1);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }

            var CS = Layers.Conv2D3x3(Layers.ElementwiseSum(O4_1, Layers.Upsample2D(O5_1)), this.Data.merge_conv_Weights, this.Data.merge_conv_Biases);

            if (this.Step != null)
            {
                this.Step(1f / 17f * 100f);
            }
            return(CS);
        }
Ejemplo n.º 2
0
        ///<summary>Выполняет прямой проход через декодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tensor Decode(Tensor input)
        {
            var Temp = input;

            if (this.Depth == DecoderType.Conv5)
            {
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv5_1_Weights, this.Data.Conv5_1_Biases);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.Upsample2D(Temp);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_4_Weights, this.Data.Conv4_4_Biases);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_3_Weights, this.Data.Conv4_3_Biases);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_2_Weights, this.Data.Conv4_2_Biases);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    this.Step(100f / 30f);
                }
            }
            if ((this.Depth == DecoderType.Conv4) || (this.Depth == DecoderType.Conv5))
            {
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_1_Weights, this.Data.Conv4_1_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.Upsample2D(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_4_Weights, this.Data.Conv3_4_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_3_Weights, this.Data.Conv3_3_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_2_Weights, this.Data.Conv3_2_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }
                    }
                }
            }
            if ((this.Depth == DecoderType.Conv3) || (this.Depth == DecoderType.Conv4) || (this.Depth == DecoderType.Conv5))
            {
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }
                    }
                }
                Temp = Layers.Upsample2D(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }
                    }
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }
                    }
                }
            }
            if ((this.Depth == DecoderType.Conv2) || (this.Depth == DecoderType.Conv3) || (this.Depth == DecoderType.Conv4) || (this.Depth == DecoderType.Conv5))
            {
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }
                    }
                }
                Temp = Layers.Upsample2D(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }
                    }
                }
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }
                    }
                }
            }
            if ((this.Depth == DecoderType.Conv1) || (this.Depth == DecoderType.Conv2) || (this.Depth == DecoderType.Conv3) || (this.Depth == DecoderType.Conv4) || (this.Depth == DecoderType.Conv5))
            {
                Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }

                    case DecoderType.Conv1:
                    {
                        this.Step(100f / 2f);
                        break;
                    }
                    }
                }
                Temp = Layers.ReLU(Temp);
                if (this.Step != null)
                {
                    switch (this.Depth)
                    {
                    case DecoderType.Conv5:
                    {
                        this.Step(100f / 30f);
                        break;
                    }

                    case DecoderType.Conv4:
                    {
                        this.Step(100f / 21f);
                        break;
                    }

                    case DecoderType.Conv3:
                    {
                        this.Step(100f / 12f);
                        break;
                    }

                    case DecoderType.Conv2:
                    {
                        this.Step(100f / 7f);
                        break;
                    }

                    case DecoderType.Conv1:
                    {
                        this.Step(100f / 2f);
                        break;
                    }
                    }
                }
            }
            return(Temp);
        }
Ejemplo n.º 3
0
        ///<summary>Выполняет прямой проход через кодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tuple <Tensor, Tensor> Encode(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D1x1(input, this.Data.Conv0_Weights, this.Data.Conv0_Biases);
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.MaxPool2D(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.MaxPool2D(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_2_Weights, this.Data.Conv3_2_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_3_Weights, this.Data.Conv3_3_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_4_Weights, this.Data.Conv3_4_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.MaxPool2D(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_1_Weights, this.Data.Conv4_1_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            var Conv4_1 = Temp;

            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_2_Weights, this.Data.Conv4_2_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_3_Weights, this.Data.Conv4_3_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_4_Weights, this.Data.Conv4_4_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.MaxPool2D(Temp);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv5_1_Weights, this.Data.Conv5_1_Biases);
            if (Step != null)
            {
                Step(100f / 30f);
            }
            Temp = Layers.ReLU(Temp);
            var Conv5_1 = Temp;

            if (Step != null)
            {
                Step(100f / 30f);
            }
            return(new Tuple <Tensor, Tensor>(Conv4_1, Conv5_1));
        }
Ejemplo n.º 4
0
        ///<summary>Выполняет прямой проход через кодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tensor Encode(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.MaxPool2D(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.MaxPool2D(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 12f * 100f);
            }
            return(Temp);
        }
        ///<summary>Выполняет прямой проход через декодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tensor Decode(Tensor Content, Tensor[] Styles)
        {
            var Temp = Layers.StyleDecorator(Content, Styles[3]);

            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_1_Weights, this.Data.Conv4_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Upsample2D(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_4_Weights, this.Data.Conv3_4_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_3_Weights, this.Data.Conv3_3_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_2_Weights, this.Data.Conv3_2_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.AdaIN(Temp, Styles[2]);
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Upsample2D(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.AdaIN(Temp, Styles[1]);
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Upsample2D(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.AdaIN(Temp, Styles[0]);
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            Temp = Layers.Conv2D7x7(Temp, this.Data.Conv_Out_Weights, this.Data.Conv_Out_Biases);
            if (this.Step != null)
            {
                this.Step(1f / 22f * 100f);
            }
            return(Temp);
        }
        ///<summary>Выполняет прямой проход через декодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tensor Decode(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_1_Weights, this.Data.Conv4_1_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Upsample2D(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_4_Weights, this.Data.Conv3_4_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_3_Weights, this.Data.Conv3_3_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_2_Weights, this.Data.Conv3_2_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Upsample2D(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Upsample2D(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
            if (this.Step != null)
            {
                this.Step(100f / 20f);
            }
            return(Temp);
        }
        ///<summary>Выполняет прямой проход через кодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tensor Encode(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.AvgPool2D(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.AvgPool2D(Temp);
            if (this.Step != null)
            {
                //this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_2_Weights, this.Data.Conv3_2_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_3_Weights, this.Data.Conv3_3_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_4_Weights, this.Data.Conv3_4_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.AvgPool2D(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_1_Weights, this.Data.Conv4_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            return(Temp);
        }
        ///<summary>Выполняет прямой проход через кодирующую нейросеть.</summary>
        ///<param name="input">Входные данные.</param>
        public Tensor[] EncodeStyle(Tensor input)
        {
            var Temp = input;

            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_1_Weights, this.Data.Conv1_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            var Conv1 = Temp;

            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv1_2_Weights, this.Data.Conv1_2_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.AvgPool2D(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_1_Weights, this.Data.Conv2_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            var Conv2 = Temp;

            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv2_2_Weights, this.Data.Conv2_2_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.AvgPool2D(Temp);
            if (this.Step != null)
            {
                //this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_1_Weights, this.Data.Conv3_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            var Conv3 = Temp;

            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_2_Weights, this.Data.Conv3_2_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_3_Weights, this.Data.Conv3_3_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv3_4_Weights, this.Data.Conv3_4_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.AvgPool2D(Temp);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.Conv2D3x3(Temp, this.Data.Conv4_1_Weights, this.Data.Conv4_1_Biases);
            if (this.Step != null)
            {
                this.Step(5f);
            }
            Temp = Layers.ReLU(Temp);
            var Conv4 = Temp;

            if (this.Step != null)
            {
                this.Step(5f);
            }
            return(new Tensor[4] {
                Conv1, Conv2, Conv3, Conv4
            });
        }