Whiax / NeuralNetworkCpp

Very basic deep learning framework in C++
MIT License
53 stars 12 forks source link

Question about Dataset #1

Closed rvt closed 3 years ago

rvt commented 3 years ago

Hey,

I noticed the dataset has a line with multiple inputs but a single output... This might raise a question if the network was designed with always one output neuron, based off double out = line[line.size() - 1]; So this raises the question if we can give it a dataset with any number of input and output neurons?

Whiax commented 3 years ago

Hi, Thanks for the question. This algorithm is able to reproduce the article from Matt Mazur which uses two outputs:

you can see that on this branch if you need to try:

The Dataset class is a class made to read a specific dataset I made (following the same format with only one output being the last number). You can set any amount of input and output to the network but you'll have to adapt the Dataset class following your needs and your format. It probably could have been done in a more generic way, sorry about that ^^'

rvt commented 3 years ago

Hey,

I made a boo boo (late night) in my changed version of the DataSet that can read the output prediction of 2 neurons and it works now as expected.

For fun I created this:

0   0   1   0
1   0   0   1
0   1   0   1
1   1   1   1

two inputs and two outputs xor and or

and modified the network to:

n.addLayer({ { "type", LayerType::INPUT },{ "size",2 }});
n.addLayer({ { "type", LayerType::STANDARD },{ "size",8} ,{ "activation",ActivationFunction::SIGMOID } });
n.addLayer({ { "type", LayerType::OUTPUT},{ "size",2} ,{ "activation",ActivationFunction::SIGMOID } });

Prediction correctly shows for

vector<double> in;
in.emplace_back(1.0);
in.emplace_back(0.0);
n.predict(in);

0.9 (or) and 0.03 (xor)

To add on, very nice article and I only understand half of it yet :) I like the fact it is written in c++ instead of all the large frameworks where to much is hidden.... So for me it's very easy to play with...