Reputation: 1200
I've got a network trained and I want to save it and be able to load it later so I don't have to re-train it... duh.
End of training code:
//Save network
SerializeObject.save(new File("encognet"),network);
Encog.getInstance().shutdown();
Loading File
BasicNetwork network = (BasicNetwork) EncogDirectoryPersistence.loadObject(new File("encognet"));
I get this error
Exception in thread "main" org.encog.persist.PersistError: Not a valid EG file.
Can anyone tell me how to fix this?
Upvotes: 2
Views: 689
Reputation: 596
I think the problem is that you are not saving the file as an .eg
extension. If this is not the problem, I'm not sure about SerializeObject.save
, but I know that EncogDirectoryPersistence
works for me.
So, test out this code for saving
public static final String FILENAME = "test_load_net.eg";
EncogDirectoryPersistence.saveObject(new File(FILENAME), network);
And then load like this
public static final String FILENAME = "test_load_net.eg";
BasicNetwork network = (BasicNetwork)EncogDirectoryPersistence.loadObject(new File(FILENAME));
Upvotes: 2