Net

case class Net(layers: LazyList[Layer])

The methods of a neural network.

Get the prediction for an input:

net.predict(List(0.4, 0.05, 0.2))

Fit network to a single observation:

net.fit(0.1, List(0.4, 0.05, 0.2), List(0.03. 0.8))

Get the JSON representation of the network:

net.json()
Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def errors(inputValues: List[Double], expectedOutput: List[Double], inParallel: Boolean): List[Double]
def fit(learningRate: Double, inputValues: List[Double], expectedOutput: List[Double]): Net

Returns the neural network with its weights adjusted to the provided observation.

Returns the neural network with its weights adjusted to the provided observation.

In order for it to be trained, it should fit with multiple observations, usually by folding over an iterator.

Value Params
expectedOutput

The expected output of the observation. It's size should be equal to the size of the output layer.

inputValues

The feature values of the observation.

learningRate

A number that controls how much the weights are adjusted to the observation.

Returns

A new neural network that has the same shape of the original, but it has learned from a single observation.

def json(): String

The JSON representation of the neural network.

The JSON representation of the neural network.

Returns

The JSON representation of the neural network.

def parFit(learningRate: Double, inputValues: List[Double], expectedOutput: List[Double]): Net

Returns the neural network with its weights adjusted to the provided observation.

Returns the neural network with its weights adjusted to the provided observation.

The calculation is performed in parallel. When the neural network has huge layers, the parallel calculation boosts the performance.

Value Params
expectedOutput

The expected output of the observation. It's size should be equal to the size of the output layer.

inputValues

The feature values of the observation.

learningRate

A number that controls how much the weights are adjusted to the observation.

Returns

A new neural network that has the same shape of the original, but it has learned from a single observation.

def parPredict(inputValues: List[Double]): List[Double]

Makes a prediction for the provided input.

Makes a prediction for the provided input.

The calculation is performed in parallel. When the neural network has huge layers, the parallel calculation boosts the performance.

Value Params
inputValues

The values of the features. Their size should be equal to the size of the input layer.

Returns

The prediction. It's size should be equal to the size of the output layer.

def predict(inputValues: List[Double]): List[Double]

Makes a prediction for the provided input.

Makes a prediction for the provided input.

Value Params
inputValues

The values of the features. Their size should be equal to the size of the input layer.

Returns

The prediction. It's size should be equal to the size of the output layer.

def svg(): String

An SVG representation of the neural network.

An SVG representation of the neural network.

Returns

The SVG representation of the neural network. The color of each neuron depends on its activation function while the transparency of the synapses depends on their weight.

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product