[Insight-developers] ItkNeuralNetworkIOTest
Hans J. Johnson
hans-johnson at uiowa.edu
Thu Aug 2 23:03:41 EDT 2007
Raghu,
I am attempting to use the ITK neural network IO classes that you have
graciously provided. I am, however, getting segmentation faults when my
network is the specialization for a
OneHiddenLayerBackPropagationNeuralNetwork, and I can not read a saved file
into .
I¹ve added the following code to the very end of itkNeuralNetworkIOTest.cxx
in an attempt to figure out what is going on:
==============================================================
//Now test reading and writing of OneHiddenLayerBackPropagationNeuralNetwork
{
typedef
itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<MeasurementVecto
rType, TargetVectorType> OneHiddenLayerBackPropagationNeuralNetworkType;
OneHiddenLayerBackPropagationNeuralNetworkType::Pointer
OneHiddenLayerNet = OneHiddenLayerBackPropagationNeuralNetworkType::New();
OneHiddenLayerNet->SetNumOfInputNodes(7);
OneHiddenLayerNet->SetNumOfHiddenNodes(13);
OneHiddenLayerNet->SetNumOfOutputNodes(5);
OneHiddenLayerNet->Initialize();
OneHiddenLayerNet->InitializeWeights();
OneHiddenLayerNet->SetLearningRate(0.001);
{
WriterType::Pointer
writerOneHiddenLayerBackPropagation=WriterType::New();
writerOneHiddenLayerBackPropagation->SetWriteWeightValuesType(2);
writerOneHiddenLayerBackPropagation->SetFileName("OneHiddenLayerNet.txt");
writerOneHiddenLayerBackPropagation->SetInput(OneHiddenLayerNet);
writerOneHiddenLayerBackPropagation->Update();
//This writing operation causes a segmentation fault at runtime
}
{
ReaderType::Pointer
readerOneHiddenLayerBackPropagation=ReaderType::New();
readerOneHiddenLayerBackPropagation->SetFileName(
"OneHiddenLayerNet.txt" );
readerOneHiddenLayerBackPropagation->SetReadWeightValuesType( 1 );
readerOneHiddenLayerBackPropagation->Update();
//The following line gives a compiler error
//OneHiddenLayerBackPropagationNeuralNetworkType::Pointer
OneHiddenLayerNet_ReadIn = readerOneHiddenLayerBackPropagation->GetOutput();
//Need some type of comparison here
}
}
==============================================================
Here is the compiler error:
/scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Rev
iew/itkNeuralNetworkIOTest.cxx: In function 'int itkNeuralNetworkIOTest(int,
char**)':
/scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Rev
iew/itkNeuralNetworkIOTest.cxx:257: error: invalid conversion from
'itk::Statistics::MultilayerNeuralNetworkBase<itkNeuralNetworkIOTest(int,
char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
char**)::TargetVectorType>*' to
'itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<itkNeuralNetwor
kIOTest(int, char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
char**)::TargetVectorType>*'
/scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Rev
iew/itkNeuralNetworkIOTest.cxx:257: error: initializing argument 1 of
'itk::SmartPointer<TObjectType>::SmartPointer(TObjectType*) [with
TObjectType =
itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<itkNeuralNetwork
IOTest(int, char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
char**)::TargetVectorType>]'
make[2]: ***
[Testing/Code/Review/CMakeFiles/itkReviewTests.dir/itkNeuralNetworkIOTest.o]
Error 1
make[1]: *** [Testing/Code/Review/CMakeFiles/itkReviewTests.dir/all] Error 2
make: *** [all] Error 2
With the compiler error line commented out, the program builds, but a
segmentation fault occurs during runtime.
Perhaps this class could be templated over the network type rather than the
input and output parameter types? Or does a special IO mechanism need to be
created for each of the Network types? The
OneHiddenLayerBackPropagationNeuralNetwork is just a special case of a
Multilayer NeuralNetwork, so I thought that the itkNeuralNetworkIO mechansim
should work.
Any help or advice would be greatly appreciated.
Thanks,
Hans
--
Hans J. Johnson, Ph.D.
Hans-johnson at uiowa.edu
278 GH
The University of Iowa
Iowa City, IA 52241
(319) 353 8587
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.itk.org/mailman/private/insight-developers/attachments/20070802/6f8869bf/attachment.html
More information about the Insight-developers
mailing list