Problem with Persistence for DataNormalization

arkas's picture

Is DataNormalization supposed to be able to be persisted out of the box or do I have to alter it?

I tried:

	
		DataNormalization norm = new DataNormalization();
                //Configure DataNormalization object here...
		EncogPersistedCollection encog = new EncogPersistedCollection(Config.FILENAME);
		encog.create();
		encog.add(Config.NORMALIZER_NAME, norm);
       

I checked the .eg file manually and the information for the data normalization object was all in there. Later I attempted to retrieve it with:

	
		File file = new File(Config.FILENAME);
		if (!file.exists()) {
			System.out.println("Can't read file: " + file.getAbsolutePath());
			return null;
		}
		EncogPersistedCollection encog = new EncogPersistedCollection(file);
		
		DataNormalization oldNorm =(DataNormalization)encog.find(Config.NORMALIZER_NAME);
		if (oldNorm == null) {
			System.out.println("Can't find network resource: "
					+ Config.NORMALIZER_NAME);
			return null;
		}
       

but I got an exception in the .find method:


Exception in thread "main" java.lang.NullPointerException
	at org.encog.persist.persistors.generic.XML2Object.loadCollection(XML2Object.java:185)
	at org.encog.persist.persistors.generic.XML2Object.loadActualObject(XML2Object.java:145)
	at org.encog.persist.persistors.generic.XML2Object.load(XML2Object.java:87)
	at org.encog.persist.persistors.generic.GenericPersistor.load(GenericPersistor.java:76)
	at org.encog.persist.PersistReader.readObject(PersistReader.java:363)
	at org.encog.persist.EncogPersistedCollection.find(EncogPersistedCollection.java:389)

arkas's picture

I found the problem.

My DataNormalizer uses my own custom class for the input fields.

I had to add the qualified name for this class in org.encog.data.classes.txt in order for the logic used by GenericPersistor (DataNormalizer's persistor) to load them from persistence.

jeffheaton's picture

Thanks for posting the solution. It gives me two important additions that we will make to Encog.

#1 Provide a better way for you to add classes to Encog's automatic XML persistor.

#2 Provide a better error message for when an unknown class is found!

Thanks.


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.