Skip to content

Commit

Permalink
Fixed docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
yaricom committed May 14, 2024
1 parent 178b312 commit 52c6a27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
16 changes: 0 additions & 16 deletions neat/network/fast_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ func NewFastModularNetworkSolver(biasNeuronCount, inputNeuronCount, outputNeuron
return &fmm
}

// ForwardSteps Propagates activation wave through all network nodes provided number of steps in forward direction.
// See also Relax for conditional activation waves propagation.
// Returns true if activation wave passed from all inputs to the outputs.
func (s *FastModularNetworkSolver) ForwardSteps(steps int) (res bool, err error) {
for i := 0; i < steps; i++ {
if res, err = s.forwardStep(0); err != nil {
Expand All @@ -144,9 +141,6 @@ func (s *FastModularNetworkSolver) ForwardSteps(steps int) (res bool, err error)
return res, nil
}

// RecursiveSteps Propagates activation wave through all network nodes provided number of steps by recursion from output nodes
// Returns true if activation wave passed from all inputs to the outputs. This method is preferred method
// of network activation when number of forward steps can not be easy calculated and no network modules are set.
func (s *FastModularNetworkSolver) RecursiveSteps() (res bool, err error) {
if len(s.modules) > 0 {
return false, errors.New("recursive activation can not be used for network with defined modules")
Expand Down Expand Up @@ -234,10 +228,6 @@ func (s *FastModularNetworkSolver) recursiveActivateNode(currentNode int) (res b
return res, err
}

// Relax Attempts to relax network (propagate activation waves) given amount of steps until giving up.
// The network considered relaxed when absolute value of the change at any given point is less
// than maxAllowedSignalDelta during activation waves propagation.
// If maxAllowedSignalDelta value is less than or equal to 0, the method will return true without checking for relaxation.
func (s *FastModularNetworkSolver) Relax(maxSteps int, maxAllowedSignalDelta float64) (relaxed bool, err error) {
for i := 0; i < maxSteps; i++ {
if relaxed, err = s.forwardStep(maxAllowedSignalDelta); err != nil {
Expand Down Expand Up @@ -309,8 +299,6 @@ func (s *FastModularNetworkSolver) forwardStep(maxAllowedSignalDelta float64) (i
return isRelaxed, err
}

// Flush Flushes network state by removing all current activations. Returns true if network flushed successfully or
// false in case of error.
func (s *FastModularNetworkSolver) Flush() (bool, error) {
for i := s.biasNeuronCount; i < s.totalNeuronCount; i++ {
s.neuronSignals[i] = 0.0
Expand All @@ -319,7 +307,6 @@ func (s *FastModularNetworkSolver) Flush() (bool, error) {
return true, nil
}

// LoadSensors Set sensors values to the input nodes of the network
func (s *FastModularNetworkSolver) LoadSensors(inputs []float64) error {
if len(inputs) == s.inputNeuronCount {
// only inputs should be provided
Expand All @@ -332,20 +319,17 @@ func (s *FastModularNetworkSolver) LoadSensors(inputs []float64) error {
return nil
}

// ReadOutputs Read output values from the output nodes of the network
func (s *FastModularNetworkSolver) ReadOutputs() []float64 {
// decouple and return
outs := make([]float64, s.outputNeuronCount)
copy(outs, s.neuronSignals[s.sensorNeuronCount:s.sensorNeuronCount+s.outputNeuronCount])
return outs
}

// NodeCount Returns the total number of neural units in the network
func (s *FastModularNetworkSolver) NodeCount() int {
return s.totalNeuronCount + len(s.modules)
}

// LinkCount Returns the total number of links between nodes in the network
func (s *FastModularNetworkSolver) LinkCount() int {
// count all connections
numLinks := len(s.connections)
Expand Down
6 changes: 4 additions & 2 deletions neat/network/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ package network
type Solver interface {
// ForwardSteps Propagates activation wave through all network nodes provided number of steps in forward direction.
// Normally the number of steps should be equal to the activation depth of the network.
// See also Relax for conditional activation waves propagation.
// Returns true if activation wave passed from all inputs to the output nodes.
ForwardSteps(steps int) (bool, error)

// RecursiveSteps Propagates activation wave through all network nodes provided number of steps by recursion from output nodes
// Returns true if activation wave passed from all inputs to the output nodes.
RecursiveSteps() (bool, error)

// Relax Attempts to relax network given amount of steps until giving up. The network considered relaxed when absolute
// value of the change at any given point is less than maxAllowedSignalDelta during activation waves propagation.
// Relax Attempts to relax network (propagate activation waves) given amount of steps until giving up.
// The network considered relaxed when absolute value of the change at any given point is less
// than maxAllowedSignalDelta during activation waves propagation.
// If maxAllowedSignalDelta value is less than or equal to 0, the method will return true without checking for relaxation.
Relax(maxSteps int, maxAllowedSignalDelta float64) (bool, error)

Expand Down

0 comments on commit 52c6a27

Please sign in to comment.