Class Node
java.lang.Object
com.github.raimannma.architecture.Node
public class Node extends Object
The type Node.
- Author:
- Manuel Raimann
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNode.NodeTypeNode types. -
Field Summary
Fields Modifier and Type Field Description ActivationactivationTypeThe Activation type.doublebiasNeuron's bias.List<Connection>gatedGated connections.Set<Connection>inIncoming connections.intindexThe Index.doublemaskUsed for dropout.Set<Connection>outOutgoing connections.ConnectionselfConnection to the node itself.Node.NodeTypetypeThe NodeType. -
Constructor Summary
Constructors Constructor Description Node(Node.NodeType type)Instantiates a new Node. -
Method Summary
Modifier and Type Method Description doubleactivate()Activates the node.voidactivate(double input)Activates the node with input value.voidclear()Resets this node.Connectionconnect(Node target, double weight)Connect this node to another node.voiddisconnect(Node target)Disconnects this node from the target node.booleanequals(Object o)static @NotNull NodefromJSON(@NotNull com.google.gson.JsonObject jsonObject)Convert a JsonObject to a node.voidgate(@NotNull Connection connection)Set this node to gate (influences) the given connection.inthashCode()booleanisNotProjectingTo(Node target)Checks if there is no connection between this node and the target node.voidremoveGate(Connection connection)Stops this node from gating (manipulating) the given connection.com.google.gson.JsonObjecttoJSON()Converts the node to a JsonObject that can later be converted back.StringtoString()
-
Field Details
-
in
Incoming connections. -
out
Outgoing connections. -
gated
Gated connections. -
self
Connection to the node itself. -
activationType
The Activation type. -
bias
public double biasNeuron's bias.- See Also:
- Neuron's bias
-
index
public int indexThe Index. -used for crossover -
type
The NodeType. -
mask
public double maskUsed for dropout. This is either 0 (ignored) or 1 (included) during training and is used to avoid overfit.
-
-
Constructor Details
-
Node
Instantiates a new Node.- Parameters:
type- the type
-
-
Method Details
-
fromJSON
@NotNull public static @NotNull Node fromJSON(@NotNull @NotNull com.google.gson.JsonObject jsonObject)Convert a JsonObject to a node.- Parameters:
jsonObject- the json object which holds the information- Returns:
- the node created from the information of the json object
-
activate
public double activate()Activates the node.When a neuron activates, it computes its state from all its input connections and 'squashes' it using its activation function, and returns the output (activation).
- Returns:
- A neuron's squashed output value.
-
activate
public void activate(double input)Activates the node with input value.When a neuron activates, it computes its state from all its input connections and 'squashes' it using its activation function, and returns the output (activation).
You can also provide the activation (a float between 0 and 1) as a parameter, which is useful for neurons in the input layer.
- Parameters:
input- the input to this node
-
connect
Connect this node to another node.- Parameters:
target- the target nodeweight- the weight value of the connection between this and the target node- Returns:
- the created connection pointing from this node to the target node
-
isNotProjectingTo
Checks if there is no connection between this node and the target node.- Parameters:
target- the target node- Returns:
- is there no connection
-
clear
public void clear()Resets this node. -
disconnect
Disconnects this node from the target node.- Parameters:
target- the target node
-
removeGate
Stops this node from gating (manipulating) the given connection.- Parameters:
connection- Connection to ungate
-
gate
Set this node to gate (influences) the given connection.- Parameters:
connection- Connection to be gated (influenced) by a node.
-
toJSON
public com.google.gson.JsonObject toJSON()Converts the node to a JsonObject that can later be converted back.- Returns:
- the created JsonObject
-
hashCode
public int hashCode() -
equals
-
toString
-