Andreas Hehn
2007-12-23 18:07:14 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi!
I have a problem using a callback function for the output of the
train_on_data with the c++-wrapper of fann-2.1.0 using VC++6.
I create a Neural Net 'nnet' within a class 'MyClass' where i defined
following methods:
void MyClass::train()
{
...
void *me = (void*)this;
nnet.set_callback(print_callback,me);
...
}
void MyClass::print_train_state(unsigned int epochs)
{
...
}
Outside of all classes and stuff, i wrote:
int print_callback(FANN::neural_net &net, FANN::training_data &train,
unsigned int max_epochs, unsigned int epochs_between_reports, float
desired_error, unsigned int epochs, void *user_data)
{
((MyClass*)user_data)->print_train_state(epochs);
return 0;
}
My Problem is 'me' and 'user_data' are not the same, and the program
doesn't jump to the Instance of MyClass. Where is the mistake?
Any ideas?
Regards,
Andreas Hehn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
iQIVAwUBR26j0oxI6GS6uTh2AQLY9w//WvreGeMj7pXMmdfOu/GfDbuO/sKvAy1g
vUHlabZDAMcwnGvC64iaZvCmbKd6/QHWVWhTjdp1QR76G12P/bNyEDm+rcBKYNxm
meSUMSR4O3eEVi4ZMG51FC2QaCystAfb6fVeis+RJZ0g/uzHKritqSgdyRyP/Qww
dOqmEJmplqBM67OcFTOpO2woIGuQQWTzfiZHNOlQgb4F7kCT5W9MqS7l6uPs0THw
LshawjjdIpbzhFLJI9LzrxJlEsBtmuVih9XuP4PozcZinViRpeUDBFbjnZP8lKsI
9TAi/k0PJGKDj1EiznOT76xyyNAOK/99Lnds6MFENAivzkXIsbf3kZc7rMJHxYTH
n5xBG+iK3Py6us4U8E5sKZxv9gaH/HoglpvvdQNSu04kYvAKzrSXseVtySFIb7+o
bZmLxGBfy/ANbTVvuU+FdNEU61pX8dXi5zu4SVRWZd2UF6RRwy1gFIge+T9Sg6y0
MyxgwiwoR8TfoIyNgVKp750g595M+73O8WOVVTGzLH0YpxOw2HiwU2W5chpSw3Hl
dV6bRkvGUk08KeKLqcEOubwN6d6p2BQX2juBSXMsA0ZBV2Gn7aSrOkvM3rtmDRc6
MwhJJsmGxdxSbgIUl0EHzHDwd92O7lhXbrBLc80r1Jkx5F5fBBh80NyuZsrUaqsS
TmXOkxjyQXU=
=ljsg
-----END PGP SIGNATURE-----
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Hash: SHA1
Hi!
I have a problem using a callback function for the output of the
train_on_data with the c++-wrapper of fann-2.1.0 using VC++6.
I create a Neural Net 'nnet' within a class 'MyClass' where i defined
following methods:
void MyClass::train()
{
...
void *me = (void*)this;
nnet.set_callback(print_callback,me);
...
}
void MyClass::print_train_state(unsigned int epochs)
{
...
}
Outside of all classes and stuff, i wrote:
int print_callback(FANN::neural_net &net, FANN::training_data &train,
unsigned int max_epochs, unsigned int epochs_between_reports, float
desired_error, unsigned int epochs, void *user_data)
{
((MyClass*)user_data)->print_train_state(epochs);
return 0;
}
My Problem is 'me' and 'user_data' are not the same, and the program
doesn't jump to the Instance of MyClass. Where is the mistake?
Any ideas?
Regards,
Andreas Hehn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
iQIVAwUBR26j0oxI6GS6uTh2AQLY9w//WvreGeMj7pXMmdfOu/GfDbuO/sKvAy1g
vUHlabZDAMcwnGvC64iaZvCmbKd6/QHWVWhTjdp1QR76G12P/bNyEDm+rcBKYNxm
meSUMSR4O3eEVi4ZMG51FC2QaCystAfb6fVeis+RJZ0g/uzHKritqSgdyRyP/Qww
dOqmEJmplqBM67OcFTOpO2woIGuQQWTzfiZHNOlQgb4F7kCT5W9MqS7l6uPs0THw
LshawjjdIpbzhFLJI9LzrxJlEsBtmuVih9XuP4PozcZinViRpeUDBFbjnZP8lKsI
9TAi/k0PJGKDj1EiznOT76xyyNAOK/99Lnds6MFENAivzkXIsbf3kZc7rMJHxYTH
n5xBG+iK3Py6us4U8E5sKZxv9gaH/HoglpvvdQNSu04kYvAKzrSXseVtySFIb7+o
bZmLxGBfy/ANbTVvuU+FdNEU61pX8dXi5zu4SVRWZd2UF6RRwy1gFIge+T9Sg6y0
MyxgwiwoR8TfoIyNgVKp750g595M+73O8WOVVTGzLH0YpxOw2HiwU2W5chpSw3Hl
dV6bRkvGUk08KeKLqcEOubwN6d6p2BQX2juBSXMsA0ZBV2Gn7aSrOkvM3rtmDRc6
MwhJJsmGxdxSbgIUl0EHzHDwd92O7lhXbrBLc80r1Jkx5F5fBBh80NyuZsrUaqsS
TmXOkxjyQXU=
=ljsg
-----END PGP SIGNATURE-----
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/