Neural Network v0.1.0 NeuralNetwork.Neuron

A neuron makes up a network. It’s purpose is to sum its inputs and compute an output. During training the neurons adjust weights of its outgoing connections to other neurons.

Summary

Functions

Activate a neuron. Set the input value and compute the output Input neuron: output will always equal their input value Bias neuron: output is always 1. Other neurons: will squash their input value to compute output

Lookup and return a neuron

Create a neuron agent

Backprop using the delta. Set the neuron’s delta value

Pass in the pid, and a map to update values of a neuron

iex> {:ok, pid} = NeuralNetwork.Neuron.start_link
...> NeuralNetwork.Neuron.update(pid, %{input: 1, output: 2, incoming: [1], outgoing: [2], bias?: true, delta: 1})
...> neuron = NeuralNetwork.Neuron.get(pid)
...> neuron.input
1
...> neuron.output
2

Functions

activate(neuron_pid, value \\ nil)

Activate a neuron. Set the input value and compute the output Input neuron: output will always equal their input value Bias neuron: output is always 1. Other neurons: will squash their input value to compute output

activation_function(input)

Sigmoid function. See more at: https://en.wikipedia.org/wiki/Sigmoid_function

Example

iex> NeuralNetwork.Neuron.activation_function(1)
0.7310585786300049
connect(source_neuron_pid, target_neuron_pid)

Connect two neurons

get(pid)

Lookup and return a neuron

learning_rate()
start_link(neuron_fields \\ %{})

Create a neuron agent

train(neuron_pid, target_output \\ nil)

Backprop using the delta. Set the neuron’s delta value.

update(pid, neuron_fields)

Pass in the pid, and a map to update values of a neuron

iex> {:ok, pid} = NeuralNetwork.Neuron.start_link
...> NeuralNetwork.Neuron.update(pid, %{input: 1, output: 2, incoming: [1], outgoing: [2], bias?: true, delta: 1})
...> neuron = NeuralNetwork.Neuron.get(pid)
...> neuron.input
1
...> neuron.output
2