Documentation of 'org.joone.net.NeuralNet' Java class
NeuralNet
org.joone.net

Class NeuralNet

  • All Implemented Interfaces:
    java.io.Serializable, java.util.EventListener, NeuralLayer, NeuralNetListener


    public class NeuralNet
    extends java.lang.Object
    implements NeuralLayer, NeuralNetListener, java.io.Serializable
    This object represents a container of a neural network, giving to the developer the possibility to manage a neural network as a whole. Thanks to it, a neural network can be saved and restored using an unique writeObject and readObject command, without be worried about its internal composition. Not only this, because using a NeuralNet object, we can also easily transport a neural network on remote machines and runnit there, writing only few and generalized java code.
    See Also:
    Serialized Form
    • Constructor Detail

      • NeuralNet

        public NeuralNet()
        Creates new NeuralNet
    • Method Detail

      • start

        public void start()
        Starts all the Layers' threads, in order to prepare the launch of the neural network in multi-thread mode. DO NOT use for single-thread mode.
        Specified by:
        start in interface NeuralLayer
      • join

        public void join()
        Waits for all the termination of all running Threads
        See Also:
        Thread.join()
      • stop

        public void stop()
        Terminates the execution of this NeuralNet independently from the threading mode activated.
      • terminate

        public void terminate(boolean notify)
        Terminates the execution of all the threads of the neural network. Used to force a neural network independently from its internal state. Use ONLY in multi-thread mode, and ONLY when the call to the stop() method doesn't give the expected results.
        Parameters:
        notify - if true, the netStopped event is raised
      • terminate

        public void terminate()
        Terminates the execution of all the threads of the neural network.
        See Also:
        this.terminate(boolean notify)
      • getInputLayer

        public Layer getInputLayer()
        Returns the input layer of the network. If the method setInputLayer has been never invoked, the input layer is found, set and returned.
      • findInputLayer

        public Layer findInputLayer()
        Returns the input layer, by searching for it following the rules written in Layer.isInputLayer. Ignores any previous call made to setInputLayer.
      • getOutputLayer

        public Layer getOutputLayer()
        Returns the output layer of the network. If the method setOutputLayer has been never invoked, the output layer is found, set and returned.
      • findOutputLayer

        public Layer findOutputLayer()
        Returns the output layer by searching for it following the rules written in Layer.isOutputLayer. Ignores any previous call made to setOutputLayer.
      • getRows

        public int getRows()
        Description copied from interface: NeuralLayer
        Returns the dimension (# of neurons) of the Layer
        Specified by:
        getRows in interface NeuralLayer
        Returns:
        int
      • setRows

        public void setRows(int p1)
        Description copied from interface: NeuralLayer
        Sets the dimension (# of neurons) of the Layer
        Specified by:
        setRows in interface NeuralLayer
        Parameters:
        p1 - The number of the neurons contained in the Layer
      • addNoise

        public void addNoise(double p1)
        Description copied from interface: NeuralLayer
        Adds a noise to the biases of the layer and to all the input synapses connected
        Specified by:
        addNoise in interface NeuralLayer
        Parameters:
        p1 - the noise's amplitude in terms of distance from zero; e.g.: a value equal 0.3 means a noise from -0.3 to 0.3
      • randomize

        public void randomize(double amplitude)
      • getBias

        public Matrix getBias()
        Description copied from interface: NeuralLayer
        Return the bias matrix
        Specified by:
        getBias in interface NeuralLayer
        Returns:
        neural.engine.Matrix
      • getAllOutputs

        public java.util.Vector getAllOutputs()
        Description copied from interface: NeuralLayer
        Returns the vector of the input listeners
        Specified by:
        getAllOutputs in interface NeuralLayer
        Returns:
        java.util.Vector
      • getLayerName

        public java.lang.String getLayerName()
        Description copied from interface: NeuralLayer
        Returns the name of the layer
        Specified by:
        getLayerName in interface NeuralLayer
        Returns:
        java.lang.String
      • setAllInputs

        public void setAllInputs(java.util.Vector p1)
        Description copied from interface: NeuralLayer
        Sets the vector that contains all the input listeners. Can be useful to set the input synapses taken from another Layer
        Specified by:
        setAllInputs in interface NeuralLayer
        Parameters:
        p1 - The vector containing the list of input synapses
      • removeAllOutputs

        public void removeAllOutputs()
        Description copied from interface: NeuralLayer
        Remove all the output listeners of the net
        Specified by:
        removeAllOutputs in interface NeuralLayer
      • getAllInputs

        public java.util.Vector getAllInputs()
        Description copied from interface: NeuralLayer
        Returns the vector of the input listeners
        Specified by:
        getAllInputs in interface NeuralLayer
        Returns:
        java.util.Vector
      • addOutputSynapse

        public boolean addOutputSynapse(OutputPatternListener p1)
        Description copied from interface: NeuralLayer
        Adds a new output synapse to the layer
        Specified by:
        addOutputSynapse in interface NeuralLayer
        Parameters:
        p1 - The new output synapse
        Returns:
        true if the output synapse has been attached sucessfully
      • setBias

        public void setBias(Matrix p1)
        Description copied from interface: NeuralLayer
        Sets the matrix of biases
        Specified by:
        setBias in interface NeuralLayer
        Parameters:
        p1 - The Matrix object containing the biases
      • setLayerName

        public void setLayerName(java.lang.String p1)
        Description copied from interface: NeuralLayer
        Sets the name of the layer
        Specified by:
        setLayerName in interface NeuralLayer
        Parameters:
        p1 - The name
      • addInputSynapse

        public boolean addInputSynapse(InputPatternListener p1)
        Description copied from interface: NeuralLayer
        Adds a new input synapse to the layer
        Specified by:
        addInputSynapse in interface NeuralLayer
        Parameters:
        p1 - The new input synapse
        Returns:
        true if the input synapse has been attached sucessfully
      • setAllOutputs

        public void setAllOutputs(java.util.Vector p1)
        Description copied from interface: NeuralLayer
        Sets the vector that contains all the output listeners. Can be useful to set the output synapses taken from another Layer
        Specified by:
        setAllOutputs in interface NeuralLayer
        Parameters:
        p1 - The vector containing the list of output synapses
      • setMonitor

        public void setMonitor(Monitor p1)
        Description copied from interface: NeuralLayer
        Sets the monitor object
        Specified by:
        setMonitor in interface NeuralLayer
        Parameters:
        p1 - The Monitor to be set
      • getMonitor

        public Monitor getMonitor()
        Description copied from interface: NeuralLayer
        Returns the monitor object
        Specified by:
        getMonitor in interface NeuralLayer
        Returns:
        java.engine.Monitor
      • removeAllInputs

        public void removeAllInputs()
        Description copied from interface: NeuralLayer
        Remove all the input listeners of the net
        Specified by:
        removeAllInputs in interface NeuralLayer
      • copyInto

        public NeuralLayer copyInto(NeuralLayer p1)
        Description copied from interface: NeuralLayer
        Copies a Layer into another one, to obtain a type-transformation from a kind of Layer to another. The old Layer is disconnected from the net, while the new Layer takes its place.
        Specified by:
        copyInto in interface NeuralLayer
        Parameters:
        p1 - neural.engine.Layer
        Returns:
        The new layer
      • addLayer

        public void addLayer(Layer layer)
      • addLayer

        public void addLayer(Layer layer,
                             int tier)
      • removeLayer

        public void removeLayer(Layer layer)
      • resetInput

        public void resetInput()
        Resets all the StreamInputLayer of the net
      • addNeuralNetListener

        public void addNeuralNetListener(NeuralNetListener listener)
      • getListeners

        public java.util.Vector getListeners()
      • removeNeuralNetListener

        public void removeNeuralNetListener(NeuralNetListener listener)
      • getVersion

        public static java.lang.String getVersion()
        Method to get the version.
        Returns:
        A string containing the version of joone's engine in the format xx.yy.zz
      • getNumericVersion

        public static java.lang.Integer getNumericVersion()
        Method to get the numeric version.
        Returns:
        an integer containing the joone's engine version
      • getLayer

        public Layer getLayer(java.lang.String layerName)
      • getLayers

        public java.util.Vector getLayers()
      • setLayers

        public void setLayers(java.util.Vector newlayers)
        Permits to initialize a neural network with a Vector containing layers.
      • setLayersList

        public void setLayersList(java.util.ArrayList list)
        Permits to initialize a neural network with an ArrayList containing layers. Added for Spring.
      • setTeacher

        public void setTeacher(ComparingElement ts)
        Sets the Teacher for this NeuralNet object
        Parameters:
        TeachingSynapse - - the new teacher. It can be null to make unsupervised this neural network
      • setListeners

        public void setListeners(java.util.Vector listeners)
      • setInputLayer

        public void setInputLayer(Layer newLayer)
      • setOutputLayer

        public void setOutputLayer(Layer newLayer)
      • isRunning

        public boolean isRunning()
        Returns true if the network is running
        Specified by:
        isRunning in interface NeuralLayer
        Returns:
        boolean
      • cloneNet

        public NeuralNet cloneNet()
        Creates a copy of the contained neural network
        Returns:
        the cloned NeuralNet
      • removeAllListeners

        public void removeAllListeners()
      • setScriptingEnabled

        public void setScriptingEnabled(boolean enabled)
        Enable/disable the scripting engine for the net. If disabled, all the event-driven macros will be not run
        Parameters:
        enabled - true to enable the scripting, otherwise false
      • isScriptingEnabled

        public boolean isScriptingEnabled()
        Gets if the scripting engine is enabled
        Returns:
        true if enabled
      • getMacroPlugin

        public MacroInterface getMacroPlugin()
        Getter for property macroPlugin.
        Returns:
        Value of property macroPlugin.
      • setMacroPlugin

        public void setMacroPlugin(MacroInterface macroPlugin)
        Setter for property macroPlugin.
        Parameters:
        macroPlugin - New value of property macroPlugin.
      • getParam

        public java.lang.Object getParam(java.lang.String key)
        Gets a custom parameter from the neural net. The user is free to use the custom parameters as s/he wants. They are useful to transport a whatever value along with the net.
        Parameters:
        key - The searched key
        Returns:
        The value of the parameter if found, otherwise null
      • setParam

        public void setParam(java.lang.String key,
                             java.lang.Object obj)
        Sets a custom parameter of the neural net. The user is free to use the custom parameters as s/he wants. They are useful to transport a whatever value along with the net.
        Parameters:
        key - The key of the param
        obj - The value of the param
      • getKeys

        public java.lang.String[] getKeys()
        Return all the keys of the parameters contained in the net.
        Returns:
        An array of Strings containing all the keys if found, otherwise null
      • check

        public java.util.TreeSet check()
        Compiles all layers' check messages.
        Specified by:
        check in interface NeuralLayer
        Returns:
        validation errors.
        See Also:
        NeuralLayer
      • netStoppedError

        public void netStoppedError(NeuralNetEvent e,
                                    java.lang.String error)
        Stops the execution threads and resets all the layers in the event of an crtitical network error.
        Specified by:
        netStoppedError in interface NeuralNetListener
        Parameters:
        error - The error message.
        e - The event source of this event.
      • setOrderedLayers

        public void setOrderedLayers(Layer[] orderedLayers)
        This method permits to set externally a particular order to traverse the Layers. If not used, the order will be calculated automatically. Use this method in cases where the automatic ordering doesn't work (e.g. in case of complex recurrent connections) NOTE: if you set this property, you're responsible to update the array whenever a layer is added/removed.
        Parameters:
        orderedLayers - an array containing the ordered layers
      • getOrderedLayers

        public Layer[] getOrderedLayers()
      • calculateOrderedLayers

        public Layer[] calculateOrderedLayers()
        This method calculates the order of the layers of the network, from the input to the output. If the setOrderedLayers method has been invoked before, that array will be returned, otherwise the order will be calculated automatically.
        Returns:
        An array containing the ordered Layers, from the input to the output (i.e. layers[0]=input layer, layers[n-1]=output layer.
      • go

        public void go(boolean singleThreadMode,
                       boolean sync)
        Runs the network.
        Parameters:
        singleThreadMode - If true, runs the network in single thread mode
        sync - If true, runs the network in a separated thread and returns immediately.
      • go

        public void go(boolean sync)
        Runs the network. The running mode is determined by the value of the singleThreadMode property.
        Parameters:
        sync - If true, runs the network in a separated thread and returns immediately.
      • go

        public void go()
        Runs the network in async mode (i.e. equivalent to go(false) ). The running mode is determined by the value of the singleThreadMode property.
      • restore

        public void restore()
        Continue the execution of the network after the stop() method is called.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.