[Insight-developers] Re: ItkNeuralNetworkIOTest

Hans J. Johnson hans-johnson at uiowa.edu
Fri Aug 3 19:25:08 EDT 2007


Raghu,

I am getting my hands dirty in this.  I¹ve found many inconsistencies, and
differences between the MultiLayer, OneHiddenLayer, and TwoHiddenLayer
versions.  This is the main cause of failure in IO mechanisms.

I¹ve made the typedefs, and exposed configuration options consistent amoung
the classes, and verified the regression tests are still passing.

The logic in the IO classes have been modified to support reading and
writing all types of neural networks that adhere to the MultiLayer base
class.  I still have a few failures, but hope to have them resolved yet this
weekend.

Once the commits are submtted, would you please review the changes and let
me know if there are additional options that need changing?

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



From: Raghu Venkatram <raghu.venkatram at gmail.com>
Date: Fri, 3 Aug 2007 00:43:03 -0400
To: "Hans J. Johnson" <hans-johnson at uiowa.edu>
Subject: Re: ItkNeuralNetworkIOTest

Hi Hans,

Great to know somebody is using ITK Neural Networks. I will try to do my
best, I have
been away from the ITK code base for almost a year now. It had gone
through the Insight Journal submission, I just checked the dashboard after a
long time, the test seems to pass. I apologize, I really want to jump in,
but its probably going to take me a while.

I have some thoughts which maybe useful,
 //OneHiddenLayerBackPropagationNeuralNetworkType::Pointer
OneHiddenLayerNet_ReadIn = readerOneHiddenLayerBackPropagation->GetOutput();
the compile error is becuase in itkNeuralNetworkFileReader.h
there is a typedef 
  typedef Statistics::MultilayerNeuralNetworkBase<TVector,TOutput>
NetworkType;


I think the compiler doesnt like the implicit conversion from this
NetworkType to 

 OneHiddenLayerBackPropagationNeuralNetwork.

While designing the IO classes I was thinking on the lines of using the
network configuration text
file to describe network topology. So you could get the same funcionality
using the test example,

by just chaning the number of nodes in each layer in the test input file
Input.txt.

I am sorry, I couldn't be of much help, I will try to tinker with it
sometime soon.

Thank you,
Raghu

On 8/2/07, Hans J. Johnson <hans-johnson at uiowa.edu> 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<MeasurementVectorT
> ype, 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/Revie
> w/itkNeuralNetworkIOTest.cxx: In function 'int itkNeuralNetworkIOTest(int,
> char**)':
> /scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Revie
> w/itkNeuralNetworkIOTest.cxx:257: error: invalid conversion from
> 'itk::Statistics::MultilayerNeuralNetworkBase<itkNeuralNetworkIOTest(int,
> char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
> char**)::TargetVectorType>*' to
> 'itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<itkNeuralNetworkI
> OTest(int, char**)::MeasurementVectorType, itkNeuralNetworkIOTest(int,
> char**)::TargetVectorType>*'
> /scratch/hjohnson/src/brains2/iplFreeware/unpackdir/Insight/Testing/Code/Revie
> w/itkNeuralNetworkIOTest.cxx:257: error:   initializing argument 1 of
> 'itk::SmartPointer<TObjectType>::SmartPointer(TObjectType*) [with TObjectType
> = 
> itk::Statistics::OneHiddenLayerBackPropagationNeuralNetwork<itkNeuralNetworkIO
> Test(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



-- 
Donald Knuth- "Beware of bugs in the above code; I have only proved it
correct, not tried it."

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.itk.org/mailman/private/insight-developers/attachments/20070803/10fd7009/attachment.html


More information about the Insight-developers mailing list