Accessing weights of cloned or stored network

Faiyaz
2008-12-05
2013-04-16
  • Faiyaz

    Faiyaz - 2008-12-05

    Hi,

    I want to be able to access the weights of a cloned or stored neural net, but I'm not sure  how to do this?  The only methods avaliable seem to ge get bias or set bias methods for the layer biases. Is there a way to access the weights associated with the synapses..??

    Thanks

     
    • UeliHofstetter

      UeliHofstetter - 2008-12-05

      hi,

      of course you can. just use the the getWeights() method of the synapse and you get a matrix of all weights associated with this synapse.

      kind regards

      u

       
    • Faiyaz

      Faiyaz - 2008-12-05

      Hi, 

      Yeah i can do that.. However say that once you have created your neural network object, saved it or have given it in another application code, then the other app has no access to the synapses and therefore the weights. You only have your NeuralNet object and you only have access to the layers. From the layers you can only access the biases rather than the actual weights, as far as i can tell.

      Putting it another way, if your given just a trained neuralNet object how can you get a handle on its synapses in order to use getWeights() to get your weights. 

      This is applicable when your progressively training and validating a network online and making a clone or copy of it and then picking the best one.

       
      • UeliHofstetter

        UeliHofstetter - 2008-12-05

        ah... i think i get your problem. so you can do sth. like this

                Iterator synIter = myDeserializedNetworkObject.getLayer("myLayer").getAllOutputs().iterator();
                while(synIter.hasNext()){
                    OutputPatternListener opl = (OutputPatternListener)synIter.next();
                    if(opl instanceof FullSynapse) {
                        FullSynapse fs = (FullSynapse)opl;
                        Matrix weights = fs.getWeights();
                        //do sth. with these weights ....
                    }
                }

        is this of any help?

        kind regards

        ueli

         
    • Faiyaz

      Faiyaz - 2008-12-05

      Cool this will help.... i actually ended up making my own versions of the layer objects i was using (inheriting from Layer), then creating two new methods to access the inputPatternListeners and outputPatternListerers protected Vectors in which the synapses are stored. However your approach seems a bit more of a cleaner way to do it... thanks..

       
    • ferra4models

      ferra4models - 2008-12-06

      Hi,

      Look at the NodesAndWeights class - only in CVS at present. It detangles a network, classifies nodes, enumerates weights, has the ability to print out a weight matrix, to change or retrieve weight values or to work directly with nodes.

      On top of this is a network viewer that is maybe what you are after? It displays and plots the network structure and the various weights. Inside joone, you can see this by using inspect.

      Regards
      MG
      http://www.ferra4models.com

       

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks