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 class
Node.NodeType
Node types. -
Field Summary
Fields Modifier and Type Field Description Activation
activationType
The Activation type.double
bias
Neuron's bias.List<Connection>
gated
Gated connections.Set<Connection>
in
Incoming connections.int
index
The Index.double
mask
Used for dropout.Set<Connection>
out
Outgoing connections.Connection
self
Connection to the node itself.Node.NodeType
type
The NodeType. -
Constructor Summary
Constructors Constructor Description Node(Node.NodeType type)
Instantiates a new Node. -
Method Summary
Modifier and Type Method Description double
activate()
Activates the node.void
activate(double input)
Activates the node with input value.void
clear()
Resets this node.Connection
connect(Node target, double weight)
Connect this node to another node.void
disconnect(Node target)
Disconnects this node from the target node.boolean
equals(Object o)
static @NotNull Node
fromJSON(@NotNull com.google.gson.JsonObject jsonObject)
Convert a JsonObject to a node.void
gate(@NotNull Connection connection)
Set this node to gate (influences) the given connection.int
hashCode()
boolean
isNotProjectingTo(Node target)
Checks if there is no connection between this node and the target node.void
removeGate(Connection connection)
Stops this node from gating (manipulating) the given connection.com.google.gson.JsonObject
toJSON()
Converts the node to a JsonObject that can later be converted back.String
toString()
-
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
-