Updating Network's train function
This commit is contained in:
parent
d499f8a29a
commit
99f6978d02
2 changed files with 10 additions and 8 deletions
|
@ -162,16 +162,17 @@ bool Network::train(const vector<vector<float>> &inputs, const vector<vector<flo
|
|||
{
|
||||
vector<vector<float>> all_activated_outputs(get_neurons_number());
|
||||
vector<vector<float>> all_derrors(get_neurons_number()-inputs.at(0).size());
|
||||
int neurons_counter1 = 0;
|
||||
int neurons_counter2 = 0;
|
||||
int layer_counter;
|
||||
int neurons_counter1;
|
||||
int neurons_counter2;
|
||||
for(int index(batch_index) ; index<inputs.size() && index<batch_index+batch_size ; index++)//batch_size not yet used
|
||||
{
|
||||
forward(inputs.at(index), targets.at(index));
|
||||
set_errors(targets.at(index));
|
||||
|
||||
int layer_counter = 0;
|
||||
//int neurons_counter1 = 0;
|
||||
//int neurons_counter2 = 0;
|
||||
layer_counter = 0;
|
||||
neurons_counter1 = 0;
|
||||
neurons_counter2 = 0;
|
||||
for(list<forward_list<Neuron>>::iterator cur_layer(layers.begin()) ; cur_layer!=layers.end() ; ++cur_layer)
|
||||
{
|
||||
layer_counter++;
|
||||
|
@ -196,7 +197,7 @@ bool Network::train(const vector<vector<float>> &inputs, const vector<vector<flo
|
|||
}
|
||||
}
|
||||
|
||||
int layer_counter = 0;
|
||||
layer_counter = 0;
|
||||
neurons_counter1 = 0;
|
||||
neurons_counter2 = 0;
|
||||
for(list<forward_list<Neuron>>::iterator cur_layer(layers.begin()) ; cur_layer!=layers.end() ; ++cur_layer)
|
||||
|
|
5
main.cpp
5
main.cpp
|
@ -11,15 +11,16 @@ int main(int argc, char *argv[])
|
|||
|
||||
cout << "Bonjour et bienvenu" << endl;
|
||||
|
||||
Network network(15, 3);/*
|
||||
Network network(2, 3);/*
|
||||
network.print();
|
||||
cout << endl << endl;
|
||||
network.train({1.0,1.0,1.0}, {1.0,2.0,3.0}, 0.001, 100000);
|
||||
//network.print();
|
||||
cout << endl << endl;
|
||||
network.print();*/
|
||||
network.train({{1.0,1.0,1.0},{2.0,1.0,1.0}}, {{1.0,2.0,3.0},{1.0,2.0,6.0}}, 0.001, 1000000, 1);
|
||||
cout << "Network has " << network.get_neurons_number() << " neurons" << endl;
|
||||
for(auto e : network.predict({{1.0,1.0,1.0},{2.0,1.3,0.0}},false))
|
||||
for(auto e : network.predict({{1.0,1.0,1.0},{2.0,1.0,1.0}},true))
|
||||
{
|
||||
cout << e << " " << endl;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue