Constructing neural net layers - problem defining floating point variable

Hi folks, I have been attempting to port dated C++ code (from a book) for a backpropagation neural network over to MS VS 2010 express, intended to be used in my psychology studies.

I have done what I can to clean/update the code, reducing errors from hundreds down to a total of 5 and am unable to fix this last issue without a little help.

Here is the relevant snippet of the code, N.B lines 6 in first code and line 7 in second code, "i+1y" with y defined earlier in the code as "float *y"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Construct the layers

layer_ptr[0] = new input_layer(0,layer_size[0]);
for (i=0;i<(number_of_layers-1);i++)
{
layer_ptr[i+1y] =
new middle_layer(layer_size[i],layer_size[i+1]);
}
layer_ptr[number_of_layers-1] = new
output_layer(layer_size[number_of_layers-2],layer_size[number_of_layers-1]);
for (i=0;i<(number_of_layers-1);i++)
{
if (layer_ptr[i] == 0)
{
cout << "insufficient memory\n";
cout << "use a smaller architecture\n";
exit(1);
}
}


and

1
2
3
4
5
6
7
// Connect the layers
//
// set inputs to previous layer outputs for all layers,
// except the input layer

for (i=1; i< number_of_layers; i++)
layer_ptr[i]->inputs = layer_ptr[i-1y]->outputs;


Producing the following errors:

Error	1	error C2059: syntax error : 'bad suffix on number'	backprop network.cpp	392
Error	2	error C2146: syntax error : missing ']' before identifier 'y'	backprop network.cpp	392
Error	3	error C2059: syntax error : 'bad suffix on number'	backprop network.cpp	413
Error	4	error C2146: syntax error : missing ']' before identifier 'y'	backprop network.cpp	413
Error	5	error C2440: '=' : cannot convert from 'layer *' to 'float *'	backprop network.cpp	413


Can anyone help me properly declare *y and use it in a function, perhaps by way of using a cast? Thank you for your help I have only been coding for 48 hours.

If y is a pointer to a floating-point integer, then you can't use it as part of an index. An index has to be an integral value (a whole number, if you will). Sorry. :(

-Albatross
Last edited on
Thank you I will try to find a new expression for the solution

Whitian
Last edited on
For anyone googling their way here with a similar issue regarding the same book, I have found that the correct expression is [i+1], I have no idea why the y is there, but a random z was also found in another .cpp file. Neural net now up and running and giving perfectly good connection weight readings on Borland Turbo C++ using dosbox on 64bit win 7. I've had quite enough of visual studio "express" that's a laugh...
Topic archived. No new replies allowed.