Hi,
I've just recently come across SimBrain and trying to become familiar. Currently, I'm just playing with backprop via the GUI. I am successfully able to train my network, and now I want to pass new inputs to the network and see what it produces. I want to pass many new rows at once and analyze the output. Is this possible? Maybe to output it to a file? Right now, the only thing I can figure is to manually click through each row and note down the output neuron values each time by hand. Eventually I can see using this as a java library, but for now using the GUI is really helping me get going. Thanks for the work. JamO |
Administrator
|
Hi there,
I've been traveling and am still not settled back in, but real quick, you can do this. Go the training dialog or the input layer (layer 1) and set inputs. Then go to the output layer (layer 3) and right click and click “start recording”. Create a file name. Then go to the input layer or training dialog, validate input data tab and click the play button. Then right click layer 3 and stop recording. Then the file you created will have all the activations. There are other ways to do this. I'll say all this more systematically and clearly and maybe make a video in the next week or so. Cheers, - Jeff |
Thanks for the reply Jeff.
the method you describe works great. Also, in the meantime before you replied I spent some time trying to use simbrain as a java library (note: I'm not a java expert, or even intermediate :) and came up with the below. It was fun digging around trying to figure out ways to do things. This is just a hack for now, to prove I could do it. But, posting it here so others might come across it for some tiny benefit. public class predictionMaker { public static void main(String[] args) { BasicConfigurator.configure(); // network file saved from simbrain GUI File networkXmlFile = new File("./jamo_networks/test2.xml"); // input and output files File inputDataFile = new File("./jamo_networks/data/10_input.csv"); File predictionDataFile = new File("./jamo_networks/data/predictions.csv"); // pull input data in to array double inputData[][]= getDoubleMatrix(inputDataFile); // found these examples in simbrain docs, and it works, but not sure any better way NetworkComponent networkComponent = (NetworkComponent) WorkspaceSerializer .open(NetworkComponent.class, networkXmlFile); Network networkWorkSpace = networkComponent.getNetwork(); // the network saved in simbrain GUI ends up as a 0th subnetwork in a "group list" List groupList = networkWorkSpace.getGroupList(); BackpropNetwork bpNet = (BackpropNetwork) groupList.get(0); // the output layer was renamed to "output" in the simbrain GUI before saving. NeuronGroup outputNeurons = bpNet.getNeuronGroupByLabel("output"); // hard coded 10 x 2 prediction array String predictions[][] = new String[10][2]; // for each of the 10 rows in the input data, set the input activations, update // the network, pull the output activations and save to prediction array, printing // output along the way for (int row = 0; row < inputData.length; row++) { for (int i = 0; i < 226; i++) { bpNet.getInputNeurons().get(i).forceSetActivation(inputData[row][i]); } bpNet.update(); String output1 = Utils.round(outputNeurons.getNeuronList().get(0).getActivation(), 2); String output2 = Utils.round(outputNeurons.getNeuronList().get(1).getActivation(), 2); System.out.print(output1 + ", " + output2 +"\n"); predictions[row][0] = output1; predictions[row][1] = output2; } // write the predictions to file writeMatrix(predictions, predictionDataFile); } } |
Free forum by Nabble | Edit this page |