mutation

Genetic algorithm mutation methods. Creates variations (mutations) in neural networks which are then selected for better performance.

Source:
See:

Examples

Mutation methods with networks

      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

// Setting a mutation method for a network
myNetwork.mutate(methods.mutation.ADD_NODE);

// specifying a list of network mutation methods to use during evolution
myNetwork.evolve(trainingset, {
 mutation: [methods.mutation.MOD_BIAS, methods.mutation.ADD_NODE]
}
    

Using a mutation method with a neuron

      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNode.mutate(methods.mutation.MOD_BIAS);
    

Members

(static, constant) ADD_BACK_CONN :object

Adds a recurrent connection

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.ADD_BACK_CONN);
    
Source:
Default Value:
  • {
      "name": "ADD_BACK_CONN"
    }

(static, constant) ADD_CONN :object

Adds a connection between two nodes

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.ADD_CONN);
    
Source:
Default Value:
  • {
      "name": "ADD_CONN"
    }

(static, constant) ADD_GATE :object

Makes a node gate a connection

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.ADD_GATE);
    
Source:
Default Value:
  • {
      "name": "ADD_GATE"
    }

(static, constant) ADD_NODE :object

Adds a node

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.ADD_NODE);
    
Properties:
Name Type Default Description
randomActivation boolean true

If enabled, sets a random activation function on the newly created node

Source:
Default Value:
  • {
      "name": "ADD_NODE",
      "randomActivation": true
    }

(static, constant) ADD_SELF_CONN :object

Adds a self-connection to a node

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.ADD_SELF_CONN);
    
Source:
Default Value:
  • {
      "name": "ADD_SELF_CONN"
    }

(static, constant) ALL :array

Array of all mutation methods

Type:
  • array
Example

A group of mutation methods for evolution

      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

network.evolve(trainingset, {
 mutation: methods.mutation.ALL // all mutation methods
}
    
Source:
Default Value:
  • [
      "mutation.ADD_NODE",
      "mutation.SUB_NODE",
      "mutation.ADD_CONN",
      "mutation.SUB_CONN",
      "mutation.MOD_WEIGHT",
      "mutation.MOD_BIAS",
      "mutation.MOD_ACTIVATION",
      "mutation.ADD_GATE",
      "mutation.SUB_GATE",
      "mutation.ADD_SELF_CONN",
      "mutation.SUB_SELF_CONN",
      "mutation.ADD_BACK_CONN",
      "mutation.SUB_BACK_CONN",
      "mutation.SWAP_NODES"
    ]

(static, constant) FFW :array

Array of all feedforwad mutation methods

Type:
  • array
Example

A group of mutation methods for evolution

      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

network.evolve(trainingset, {
 mutation: methods.mutation.FFW// all feedforward mutation methods
}
    
Source:
Default Value:
  • [
      "mutation.ADD_NODE",
      "mutation.SUB_NODE",
      "mutation.ADD_CONN",
      "mutation.SUB_CONN",
      "mutation.MOD_WEIGHT",
      "mutation.MOD_BIAS",
      "mutation.MOD_ACTIVATION",
      "mutation.SWAP_NODES"
    ]

(static, constant) MOD_ACTIVATION :object

Modifies the activation function of a node by randomly picking from the allowed activation methods

Type:
  • object
Examples

Mutating the activation function of a node

      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

let myNode = new Node();

myNode.mutate(methods.mutation.MOD_ACTIVATION);
    

Mutating the activation function of a network's nodes

      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

let myNode = new Node();

myNode.mutate(methods.mutation.MOD_ACTIVATION);
    
Properties:
Name Type Attributes Default Description
mutateOutput boolean false

Change activation function of network output neurons. Enable this to let the network experiment with its output.

allowed Array.<activation> <optional>
[all built-in activation methods]

Mutation methods to randomly select from when mutating

Source:
Default Value:
  • {
      "name": "MOD_ACTIVATION",
      "mutateOutput": false,
      "allowed": ""
    }

(static, constant) MOD_BIAS :object

Modifies the bias of a node

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

let myNode = new Node();

myNode.mutate(methods.mutation.MOD_BIAS);
    
Properties:
Name Type Default Description
min number -1

lower bound for modification of a neuron's bias

max number 1

higher bound for modification of a neuron's bias

Source:
Default Value:
  • {
      "name": "MOD_BIAS",
      "min": "",
      "max": 1
    }

(static, constant) MOD_WEIGHT :object

Modifies the weight of a connection

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.MOD_WEIGHT);
    
Properties:
Name Type Default Description
min number -1

lower bound for weight modification

max number 1

higher bound for weight modification

Source:
Default Value:
  • {
      "name": "MOD_WEIGHT",
      "min": "",
      "max": 1
    }

(static, constant) SUB_BACK_CONN :object

Removes a recurrent connection

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.SUB_BACK_CONN);
    
Source:
Default Value:
  • {
      "name": "SUB_BACK_CONN"
    }

(static, constant) SUB_CONN :object

Removes a connection between two nodes

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.SUB_CONN);
    
Source:
Default Value:
  • {
      "name": "REMOVE_CONN"
    }

(static, constant) SUB_GATE :object

Removes a gate from a connection

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.SUB_GATE);
    
Source:
Default Value:
  • {
      "name": "SUB_GATE"
    }

(static, constant) SUB_NODE :object

Removes a node

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.SUB_NODE);
    
Properties:
Name Type Default Description
keep_gates boolean true

Ensures replacement node has gated connections if the removed node did.

Source:
Default Value:
  • {
      "name": "SUB_NODE",
      "keep_gates": true
    }

(static, constant) SUB_SELF_CONN :object

Removes a self-connection from a node

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.SUB_SELF_CONN);
    
Source:
Default Value:
  • {
      "name": "SUB_SELF_CONN"
    }

(static, constant) SWAP_NODES :object

Swaps the bias and squash function between two nodes

Type:
  • object
Example
      Copy
      let { methods, Network } = require("@liquid-carrot/carrot");

let myNetwork = new Network(5, 10, 5);

myNetwork.mutate(methods.mutation.SWAP_NODES);
    
Properties:
Name Type Default Description
mutateOutput boolean false

Swap bias and activation function of network output neurons too. Disable this to keep output of a neural network normalized.

Source:
Default Value:
  • {
      "name": "SWAP_NODES",
      "mutateOutput": false
    }