#Unresolved External Symbol

6 messages · Page 1 of 1 (latest)

lilac bayBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

final ore
#
#include <iostream>
#include "Matrix.h"
#include <list>
#include "Layer.h"

namespace NeuralNetwork
{
    class NeuralNetwork
    {
    public:

        std::vector<Layer> Layers;

        void Train(int const& epochs, double const& learnRate, std::vector<std::pair<Mat::Matrix, Mat::Matrix>> const& dataset)
        {
            for (int i = 0; i < epochs; i++)
            {
                for (auto const& data : dataset)
                {

                    Mat::Matrix target = data.second;

                    Mat::Matrix const& input = data.first;

                    Mat::Matrix res = input;

                    std::vector<Mat::Matrix> layerOutputs(Layers.size());
                    layerOutputs[0] = input;

                    //Forward

                    for (int i = 1; i < Layers.size(); i++)
                    {
                        Layers[i].Inputs = res;
                        Mat::Matrix o = Layers[i].Calculate();
                        res = o;
                        layerOutputs[i] = res;
                    }

                    Mat::Print(res);

                    //Backward

                    std::vector<Mat::Matrix> layerErrors(Layers.size());
                    layerErrors[Layers.size() - 1] = Mat::Sub(layerOutputs[Layers.size() - 1], target);

                    for (int i = Layers.size() - 1; i >= 0; i--) //Might be - 2 not - 1
                    {
                        layerErrors[i] = Mat::Mul(layerErrors[i + 1], Layers[i].Weights);
                    }

                    //Gradient Descent

                    for (int i = 1; i < Layers.size(); i++)
                    {
                        Mat::Matrix change = Mat::Mul(layerOutputs[i], layerErrors[i + 1]);
                        Mat::Mul(change, -learnRate);
                        Layers[i].Weights = Mat::Add(Layers[i].Weights, change);
                    }
                }
            }
        }
    };
};
#

Had to send code in a separate message due to message size

#

I dont know how to simplify my question because I just started learning C++ a couple days ago

normal isle
#

C++ goes in #1013107104678162544

final ore
#

my bad