[Insight-developers] ItkNeuralNetworkIOTest : Code coverage...

Hans Johnson hans-johnson at uiowa.edu
Fri Aug 3 09:30:22 EDT 2007


Luis,

I am working on expanding the test suite,  and will probably have a commit
by the end of today.

The bad news is that in expanding the test suite, it will make Review builds
of ITK show up with segmentation faults on the dashboard.

Hans
-- 
Hans J. Johnson, Ph.D.
Hans-johnson at uiowa.edu

278 GH
The University of Iowa
Iowa City, IA 52241
(319) 353 8587


> From: Luis Ibanez <luis.ibanez at kitware.com>
> Date: Fri, 03 Aug 2007 08:55:10 -0400
> To: "Hans J. Johnson" <hans-johnson at uiowa.edu>
> Cc: <raghu.venkatram at gmail.com>, ITK <insight-developers at itk.org>
> Subject: Re: [Insight-developers] ItkNeuralNetworkIOTest : Code coverage...
> 
> 
> A good reminder that we should require 100% coverage
> on the code that enters the Code/Review directory.
> 
> The Mantra:
> 
> 
>        "If it is not tested, it is broken"
> 
> 
> proves to be true once again....
> 
> 
>     Luis
> 
> 
> ---------------------------
> Hans J. Johnson wrote:
>> 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<MeasurementVector
>> Type, 
>> 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/Revi
>> ew/itkNeuralNetworkIOTest.cxx:
>> In function 'int itkNeuralNetworkIOTest(int, char**)':
>> /scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Revi
>> ew/itkNeuralNetworkIOTest.cxx:257:
>> error: invalid conversion from
>> 'itk::Statistics::MultilayerNeuralNetworkBase<itkNeuralNetworkIOTest(int,
>> char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
>> char**)::TargetVectorType>*' to
>> 'itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<itkNeuralNetwork
>> IOTest(int, 
>> char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
>> char**)::TargetVectorType>*'
>> /scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Revi
>> ew/itkNeuralNetworkIOTest.cxx:257:
>> error:   initializing argument 1 of
>> 'itk::SmartPointer<TObjectType>::SmartPointer(TObjectType*) [with
>> TObjectType = 
>> itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<itkNeuralNetworkI
>> OTest(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
>> 
>> 
>> ------------------------------------------------------------------------
>> 
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list