Hi!
I am working on a neural network where I have a superclass Neuron that has been extended to InputNeuron, HiddenNeuron and OutputNeuron. In the NeuralNetwork class, I am writing a function where I need to iterate through the different layers of the network. At one point, I check whether or not there are hidden layers (in which case the first of these should be connected to the input layer) or not (in which case the input layer should be directly connected to the output layer). Instead of writing two for-loops, I was thinking that one could do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
vector<Neuron*>::iterator beg_it, end_it;
if ( num_layers > 0 ) {
beg_it = layers[0].begin(); // layers =
end_it = layers[0].end(); // vector< vector<HiddenNeuron> >
}
else {
beg_it = outputs.begin(); // outputs =
end_it = outputs.end(); // vector<OutputNeuron>
}
// Connections
for (beg_it; beg_it < end_it; beg_it++) {
iss >> weight;
(**it).addConnection(weight, *beg_it);
}
| |
Unfortunately, this does not seem to work. I get the following error message for lines 3, 4, 7 and 8:
> error: no match for ‘operator=’ in ‘end_it = ...
I have tried both static and dynamic casts, resulting in:
> error: no matching function for call to ...
I'm not that well-versed in C++, so if I was trying to do something considered blatantly stupid, please explain how things work thoroughly. Any help would be appreciated, I've spent a few hours on Google and the reference section here, but to no avail.
Thanks.