Net

object Net

The constructors of a neural network.

There are four ways to create a neural network:

  1. By providing its layer sizes. This constructor creates a random sigmoid neural network.
val net = Net(List(2, 3, 1))
  1. By providing its layer sizes and a seed. This constructor creates a non-random sigmoid neural network.
val net = Net(List(4, 6, 8, 5, 3), 1000)
  1. By providing its JSON representation.
val net = Net("""[[{"activationF":"sigmoid","weights":[-0.4,-0.1,-0.8]}]]""")
  1. By providing the size, the activation function and the weights for each layer.
val net = Net(List(4, 8, 3), _ => Fun.tanh, _ => Random().nextDouble())
Companion
class
trait Product
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Inherited from
Mirror

Value members

Concrete methods

def apply(layerSizes: List[Int], activationF: Int => Fun, weightInitF: Int => Double): Net

Creates a neural network.

Creates a neural network.

Value Params
activationF

A function that accepts the index of a layer and returns an activation function for its neurons.

layerSizes

The size of each layer.

weightInitF

A function that accepts the index of a layer and returns a weight for the synapses of its neurons.

Returns

A new neural network.

def apply(layerSizes: List[Int]): Net

Creates a random neural network.

Creates a random neural network.

The activation function of all neurons is sigmoid. The weight distribution of the synapses is normal between -1.0 and 1.0.

Value Params
layerSizes

The size of each layer. The first number in the list defines the size of the input layer. The last number in the list defines the size of the output layer. In order for a neural network to be deep, the list should contain more than two numbers.

Returns

A new neural network.

def apply(layerSizes: List[Int], seed: Long): Net

Creates a non-random neural network.

Creates a non-random neural network.

Calling this function with the same parameters multiple times, should always return the same neural network. The activation function of the nodes is sigmoid. The weight distribution of the synapses is normal between -1.0 and 1.0.

Value Params
layerSizes

The size of each layer.

seed

A number used to initialize the internal pseudorandom number generator.

Returns

A new neural network.

def apply(json: String): Net

Parses a neural network.

Parses a neural network.

Value Params
json

The JSON representation of a neural network.

Returns

A neural network.