You are here

Load network from eg file with Encog 3.0

Hi,

could you please explain how to load a network from a file in the new version since EncogPersistedCollection was removed?

Neural Network Forums: 
fxmozart's picture

2 ways:

Encog.Utility.NetworkUtil.NetWorkUtility.LoadNetwork(string directory, string file)
Example :

var mynet = Encog.Utility.NetworkUtil.NetWorkUtility.LoadNetwork(@"c:\encognetworks","mynetworkfile");

//don't need to cast into a basic network i already do it in the method.

OR (the way jeff made it, which is the real way if you want to understand the behind the scenes):

FileInfo networkFile = FileUtil.CombinePath(new FileInfo(directory), file);
// network file
if (!networkFile.Exists)
{
Console.WriteLine(@"Can't read file: " + networkFile);
return null;
}
var network = (BasicNetwork)EncogDirectoryPersistence.LoadObject(networkFile);

jeffheaton's picture

Thanks for the contributions, the shortcut methods look very good. I will have to take a further look soon. I, or someone, will port those to the Java side.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer