#3 Java errors reading network from disk

closed
nobody
None
5
2010-12-12
2010-12-02
David
No

When I read a network in nxml format from disk into easy neurons and then calculate the network, java generates a NullPointerException when the observers are called. I traced the problem to null entries in the network's observers vector. Null entries are added when the network is created because that's what's written to disk when the network is saved. I modivied loadNeuralNetwork as shown below to clear the observers vector.

public NeuralNetwork loadNeuralNetwork(String filePath) {
NeuralNetwork nnet;
String fileExtension = FileUtils.getExtension(filePath);
if (fileExtension == null) {
fileExtension = FileUtils.nn;
}

try {
if (fileExtension.equals(FileUtils.nn)) {
nnet = NeuralNetwork.load(filePath);
} else if (fileExtension.equals(FileUtils.nxml)) {
NeuralNetworkXmlFile xmlFile = new NeuralNetworkXmlFile();
nnet = xmlFile.load(filePath);
// Delete observers recorded in the on disk version of the net.
nnet.deleteObservers();
return nnet;
}
} catch (Exception e) {
e.printStackTrace();
}

return null;
}

Discussion

  • Zoran Sevarac

    Zoran Sevarac - 2010-12-03

    Thanks for this patch!

     
  • Zoran Sevarac

    Zoran Sevarac - 2010-12-12

    Thanks, the patch has been applied

     
  • Zoran Sevarac

    Zoran Sevarac - 2010-12-12
    • status: open --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks