M
MathStuf
I am making a neural network where a layer keeps track of its parent
and child through the ctor. However, I have hit a snag on how to
initialize them in the wrapper class. In the wrapper class, I have an
pointer to a pointer of Layers. Then I malloc space for each. How do I
assign the parent/child relationship from this? I am thinking
something like this:
layers = (Layer **)malloc(numLayers * sizeof(Layer *));
for (int i = 0; i < numLayers; ++i)
layers = (Layer *)malloc(sizeof(Layer));
layers[0] = &Layer(NULL, layers[1], numNodes[0]);
for (int i = 1; i < numLayers - 1; ++i)
layers = &Layer(layers[i - 1], layers[i + 1], numNodes);
layers = &Layer(layers[i - 1], NULL, numNodes);
Only, I don't think that this is legal due to the temporary instances
of Layer. Any ideas on how to get this to work?
and child through the ctor. However, I have hit a snag on how to
initialize them in the wrapper class. In the wrapper class, I have an
pointer to a pointer of Layers. Then I malloc space for each. How do I
assign the parent/child relationship from this? I am thinking
something like this:
layers = (Layer **)malloc(numLayers * sizeof(Layer *));
for (int i = 0; i < numLayers; ++i)
layers = (Layer *)malloc(sizeof(Layer));
layers[0] = &Layer(NULL, layers[1], numNodes[0]);
for (int i = 1; i < numLayers - 1; ++i)
layers = &Layer(layers[i - 1], layers[i + 1], numNodes);
layers = &Layer(layers[i - 1], NULL, numNodes);
Only, I don't think that this is legal due to the temporary instances
of Layer. Any ideas on how to get this to work?