• Advertisement
Sign in to follow this  

Unhandled exception in dgbheap.c

This topic is 4418 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to do a neural network (its now like the fifth rewrite or something, hehe [smile]). Problem is, when I run it, I get an unhandled exception in dgbheap.c so I dont know what line in my code that causes it. When I step through the code the error occurs on the return line in main.
#include <iostream>
#include <conio.h>

#include "NeuralNet.h"

int main() {
	NeuralNet X(2, 2, 1);

	cout << X.Process();

	getch();
	return 1;
}

The NeuralNet class's deconstructor doesnt have any code, the class doesnt have any pointers so I dont have to delete anything manually (i think).
#ifndef _NEURAL_NET
#define _NEURAL_NET

#include <vector>
#include <iostream>
#include <time.h>
#include <math.h>

using namespace std;

class NeuralNet {
private:
	vector<vector<float> > W;	// weights 
	vector<vector<float> > X;	// the neurons outputs

	int Inputs, NeuronsInHidden, Outputs;

public:
			NeuralNet(int _Inputs, int _NeuronsInHidden, int _Outputs);
			~NeuralNet();

	float	Process();

	float	x(int l, int n);		// output x in layer l from neuron n
	float	w(int l, int f, int n);	// weight of input f (bias = 0) for neuron n in layer l

	float	Sigmoid(float num)	{return (float)(1/(1+exp(-num)));}
};

#endif

Any ideas of what could be causing this error?

Share this post


Link to post
Share on other sites
Advertisement
The most likely problem is that you're writing past the end of your vectors.

Share this post


Link to post
Share on other sites
@superpig: "Unhandled exception at 0x7c901230 in BPNet2.exe: User breakpoint" is the window that pops up. The only other output window I can think of is the that of the compilation but the program compiles just fine.

@SiCrane: I dont write to any vectors after main returns (obviously), you still think that could be the problem?

Share this post


Link to post
Share on other sites
What's probably happening is that the debug heap is detecting heap corruption when freeing memory in the vectors, which happens when main exists and the vectors in your neural net class are destroyed. The most likely cause of heap corruption when using vectors is writing past the end.

Share this post


Link to post
Share on other sites
I've been confused over that error too many times. A good tip is to check the stack trace to see which part of your/their code that causes the error. Last time I got that error I had some multithreading synchonization errors which made my vector-iterators go past the end of the vector.

Share this post


Link to post
Share on other sites
Thanks... the error is gone now... I dont know what I did but its gone :S Hehe... thanks anyway. [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement