Hello
I am trying to use simbrain networks for an agent based simulation. I have created a network in simbrain and saved it in xml format. I have a simulation written in java (repast simphony) and in each time step i want to do the following -create a vector of doubles -feed it to the network -get output in a vector of doubles In the next time step i want to use the same neural network with any updates already made. I have already classpathed the simbrain.jar in my project in eclipse and i need to create a function like function(Vector<Double> input, NeuralNetwork in xml)-> (Vector<Double> output, UpdatedNeuralNetwork) which will iterate the network once with the given input and return the updated version of the net (to use in the next time step) and the output vector. Is there any way to achieve this? Thanks Panos |
Administrator
|
Hi Panos,
You should be able to access the network from xml using something like this Network newNetwork = (Network) Network.getXStream().fromXML(xmlFile); Once you have a network object the rest of what you are doing should be straightforward. You can consult the scripts for example code. I'd suggest creating the network from xml somewhere else in your code, rather than repeatedly opening from xml every time you want to get an input / output pair. - Jeff |
Hello Jeff and thanks for the immediate answer I try to do it with the following simple class but it doesn't seem to workimport org.simbrain.network.core.Network; public class test { public static void main(String[] args) { Network newNetwork = (Network) Network.getXStream().fromXML("Mousebrain.xml"); } } Exception in thread "main" com.thoughtworks.xstream.io.StreamException: : Content is not allowed in prolog. Any help would be helpful, as I am far from expert on xml handling in Java Thanks Panos PS2. Even if i retrieve the network, will i be able to update it and save it for the next iteration? 2017-01-30 21:11 GMT+02:00 jyoshimi [via Simbrain] <[hidden email]>: Hi Panos, |
Administrator
|
Hi there,
Could you try it on a simple network you create in simbrain first. Also, have you confirmed that that xml file opens fine from Simbrain gui? - Jeff |
Nope. It doesn't work. Even the simplest network, saved in xml file, which opens normally via the Simbrain GUI, produces the same error when trying to read it usingNetwork newNetwork = (Network) Network.getXStream().fromXML( 2017-02-01 17:10 GMT+02:00 jyoshimi [via Simbrain] <[hidden email]>: Hi there, |
Administrator
|
Hi there,
Ok I created my own project and now I get the same error as you. It seems to be some weird xstream bug. To fix I had to deserialize the xml with a FileReader, like this Network newNetwork = (Network) Network.getXStream().fromXML(new FileReader(FILE_NAME)); Then I was able to open the file from the command line. Let me know if that works. If not I can post the simple test code I used. - Jeff |
Yeap! It works! Thanks a lot Jeff!2017-02-11 0:05 GMT+02:00 jyoshimi [via Simbrain] <[hidden email]>: Hi there, |
Free forum by Nabble | Edit this page |