Neural Network Library for PHP

bannerclubΤεχνίτη Νοημοσύνη και Ρομποτική

20 Οκτ 2013 (πριν από 3 χρόνια και 7 μήνες)

76 εμφανίσεις

Neural Network Library for PHP

(PHPANN)



1.

Class Name:
PHPANN
_Training
Algorithm

Description:
Handles the algorithms that are associated with Training a
connection

s weights
. C
ollection of 15 constant training algorithms us
ed in
training.



Members:



-

tr
a
i
ningRule
: The training rule that has been selected.

(String)




Methods:



+
PHPANN_TrainingAlgorithm()




Description: Constructor.



Parameter: String Layer Type



Return: N/A



+
PHPANN_TrainingAlgorithm()




Descripti
on: Constructor



Parameter: N/A



Return
: N/A




+

calculate():

C
alculates the training rule that was selected.


Parameters: Learning Rate, Network Output, Desired Output, Connection.



Return: N
umerical weight value.




-

n
ame_of_algorithm
()
:
Internal function that implements the algorithm
.


Parameter: Learning Rate, Network Output, Desired Output, Connection.


Return: Numerical weight value.



Training Rules to Implements.




PERCEPTRON_
TRAINING
_RULE



DELTA_
TRAINING_
RULE



_____ #3



_____ #4



_____ #5



_____ #6



_____ #7



_____ #8



_____ #9



_____ #10



_____ #11



_____ #12



_____ #13



_____ #14



_____ #15








2.

Class Name: PHPANN_Train
ingRule

Description:

Handles the
training
properti
es
of
the connection’s weights.


Members

-

trainingRule
: The training rule that has been selected. (String)


-

output
:


The output of the calculation using the training algorithm. (INT)

-

listOfConn
: A list of connections used in the Training Algori
thm.





Array
-
(Connection conn)



-

connection The Connections being trained.



Methods





PHPANN_TrainingRule()

Description:

Constructor

Parameter: N/A

Return:

N/A




PHPANN_TrainingRule()

Description:

Const
ructor

Parameter: Training Rule, Array (List of Conn)
, Conn being trained


Return:

N/A




set
TrainingRule
(
)

Description: Set the training/learning algorithm for the Neural Network.

Parameters: Constant
-

PHPANN_TrainingAlgorithm

Return: N/A




set
Conn()

Description: Sets the connections that will be used in the training. Only


the weights will be used.



Parameters: Array


(Connections conn)



Return: N/A




get
TrainingRule
()

Description: Returns the training rule that is bein
g used by the Neural


Network.

Return: Training Rule (String)




getConn()

Description: Returns the connections being trained.


Return: Numerica
l

Value




getNewWeight()

Description: Returns the new weight calculated by the spec
ified training

rule.



Return: Numerical Value.




calculate

()




Description:

calculates the weight for the connection.





3.

Class Name: PHPANN_
LayerType

Description:

Contains the types of layers a Layer can be


Members

+
HIDDEN
: String

constant for a HIDDEN

Layer.

+
INPUT
: String constant for a I
NPUT

Layer.

+
OUTPUT
: String constant
for a O
UTPUT

Layer.



Methods:



PHPANN_LayerType()

Description: Constructor

Parameter: N/A

Return: N/A
















4.

Class Name: PHPA
NN_
Layer

Description:
Handles the Layer properties of the Neural Network.


Members:

-

typeOfLayer
: string constant the user defines from the list of


PHPANN_LayerType.

-

neuronLibrary
: a collection of
neurons in the layer. Array (Neurons)




M
ethods:




PHPANN_Layer()

Description: Constructor

Parameter: N/A

Return: N/A




PHPANN_Layer()

Description: Constructor

Parameter: typeOfLayer (String), Array (Neuron neurons)

Return: N/A




setTypeOfLayer()



Description: Sets the type o
f layer in.



Parameter: PHPANN_LayerType



Return: N/A




addNeuron()

Description
: Adds a neuron to the Layer Instance.

Parameter: Neuron Id

Return: N/A




removeNeuron()

Description: Removes a neuron from the Collection of Neurons f
or the
Layer instance.

Parameter: Neuron Id

Return : N/A





removeAllNeuron()

Description: Remo
v
e
s all the neurons in the Collection of the Layer
Instance.

Parameter: N/A

Return: N/A




getNumberOfNeurons()

Description: Returns the t
otal number of neurons in the layer.

Parameter: N/A

Return: N/A




getLayerType()

Description: Returns the type of layer.

Parameter: N/A

Return: N/A





5.

Class Name:
PHPANN_ConnectionCollection

Description: Handles the connection po
ol throughout the neural network.


Members:

-

connectionLibrary: Array of connections
to populate
.




Methods:



ConnectionCollection()

Description: Constructor.

Parameter: N/A

Return: N/A




ConnectionCollection()

Description: Constructor.

Param
eter: Array (Connection conn)

Return: N/A




add()

Description: Adds a Connection to the Collection.

Parameter: (Connection Conn)

Return: N/A




remove()

Description: Removes a Connection from the collection.

Parameter: Connectio
n Id

Return: N/A




r
emoveAll()

Describe: Removes all the Connections in the collection.

Parameter: N/A

Return: N/A







size()

Description: Returns the size of the connection library.

Parameter: N/A

Return: Numerical val
ue.




getOutgoingConnections()

Description: Returns all outgoing connections for a neuron

Parameter: Neuron Id

Return: Numerical value.




get
Incoming
Connections()

Description: Returns all incoming connections for a neuron

Parameter: N
euron Id

Return: Numerical value.



6.

Class Name: PHPANN_ActivationRule

Description: Handles all properties for the activation rule on a given Neuron.



Members:

-

activationrule: contains the activation rule that has been selected.

-

output:
output of the activation rule.



Methods:




setActivation
Rule
()

Description: Sets the activation rule from PHPANN_ActivationAlgorithm

Parameter: PHPANN_ActivationAlgorithm

Return: N/A




get
Activation
Rule
()

Description: Returns the activation ru
le that was selected.

Parameter: N/A

Return: N/A




calculate()

Description: Process calculations using the algorithm implemented.

Parameter: N/A

Return: N/A




getOutput()

Description: Returns the calculated output using the activation

rule
specified.

Parameter: N/A

Return: N/A






7.

Class Name: PHPANN_Activation
Algorithm

Description: Handles the ty
pe of activation algorithm used.


Members:


-

activationrule:
holds the activation rule that has been set
.



Methods
:


c
alcula
te()

Description: Calculates the activation value for the neuron.

Parameter: PHPANN_ActivationAlgorithm

Return: Numerical Value


S
igmoid_Activation_
Function
()

Description: Calculates the activation value for the neuron using the Sigmoid



algorithm.

Parameter: N/A.

Return: Numerical Value.



Hyperbolic
_
Tangent
_
Function()

Description: Calculates the activation value for the neuron using the Hyperbolic


Tanget Function

Parameter: N/A.

Return: Numerica
l Value.



Linear Function()

Description: Calculates the activation value for the neuron using the Linear
Function.

Parameter: N/A.

Return: Numerical Value.


Radial Basis Function()

Description: Calculates the activation value for the neuron

using Radial Basis
Function.

Parameter: N/A.

Return: Numerical Value.





Threshold()

Description: Calculates the activation value for the neuron using the Threshold
Algorithm.

Parameter: N/A.

Return: Numerical Value.





Activa
tion Rule Algorithms Implemented


a.

Sigmoid Activation Function


b.

Hyperbolic Tangent Function

c.

Linear Function

d.

Radial Basis Function

e.

Threshold





8.

Class Name:
PHPANN_Neuron


Members:

-

Connection conn



Methods:





PHPANN_Neuron()



Description: Con
structor.


Parameter: Connection conn


Return:

N/A




PHPANN_Neuron()



Description: Constructor.


Parameter: N/A


Return:

N/A




setConnection()



Description: Sets the connection object for the neuron.


Parameter:

Connection conn


Return:

N/A








getConnection()



Description: Returns the connection object.


Parameter: N/A


Return:

Connection conn




getInput()

Description: Returns the input for the Connection object associated with


the neuron.


Parameter: N/A


Return:

Numerical Value.





getWeight()

Description: Returns the weight for the Connection object associated with


the neuron.


Parameter: N/A


Return:

Numerical Value.




9.

Class

Name:
PHPANN


Members
:


-

l
ayers
: Contains a reference to the layers being used.


-

connection; Contains a reference to the connections within the Neural


Network.

-

biasedweight: Contains the biased weight used in the neural n
etwork.






create()


Description: Creates a new Neural Network


Parameter: N/A


Return:


N/A




create()


Description: Creates a new Neural Network


Parameter: Layers layer, ConnectionCollection c
onn, biasedweight


Return:


N/A




run()


Description: Executes/Runs the Neural Network.


Parameter: N/A


Return:


N/A





setLayers()


Description: Sets the layers that will be used in the Neural Ne
twork


Parameter: Layer layer


Return:


N/A




setConnections()


Description: Sets the connections used in the Neural Network


Parameter: Connection Collection conn


Return:


N/A





setBiasedWeight()



Description: Sets the biased weight for the neural network inputs.


Parameter: Numerical Value.


Return:


N/A




getBiasedWeight()


Description: Returns the biased weight for the neural network.


Parameter:

N/A


Return:


Numerical Value.




getConnections()


Description: Returns the collection of connections used thoughout the neural


network


Parameter: N/A


Return:


ConnectionCollection conn




getLayers()



Description: Returns the Layers in the Neural Network.


Parameter: N/A


Return:


Layer layers