Architecture module
ControllerFormats.Architecture — Module
ArchitectureModule containing data structures to represent controllers.
Neural networks
An artificial neural network can be used as a controller.
General interface
ControllerFormats.Architecture.AbstractNeuralNetwork — Type
AbstractNeuralNetworkAbstract type for neural networks.
Notes
Subtypes should implement the following method:
layers(::AbstractNeuralNetwork)- return a list of the layers
The following standard methods are implemented:
length(::AbstractNeuralNetwork)getindex(::AbstractNeuralNetwork, indices)lastindex(::AbstractNeuralNetwork)==(::AbstractNeuralNetwork, ::AbstractNeuralNetwork)
ControllerFormats.Architecture.layers — Method
layers(N::AbstractNeuralNetwork)Return a list of the layers of a neural network.
Input
N– neural network
Output
The list of layers.
The following non-standard methods are implemented:
ControllerFormats.Architecture.dim_in — Method
dim_in(N::AbstractNeuralNetwork)Return the input dimension of a neural network.
Input
N– neural network
Output
The dimension of the input layer of N.
ControllerFormats.Architecture.dim_out — Method
dim_out(N::AbstractNeuralNetwork)Return the output dimension of a neural network.
Input
N– neural network
Output
The dimension of the output layer of N.
ControllerFormats.Architecture.dim — Method
dim(N::AbstractNeuralNetwork)Return the input and output dimension of a neural network.
Input
N– neural network
Output
The pair $(i, o)$ where $i$ is the input dimension and $o$ is the output dimension of N.
Notes
This function is not exported due to name conflicts with other related packages.
Implementation
ControllerFormats.Architecture.FeedforwardNetwork — Type
FeedforwardNetwork{L} <: AbstractNeuralNetworkStandard implementation of a feedforward neural network which stores the layer operations.
Fields
layers– vector of layer operations (seeAbstractLayerOp)
Notes
The field layers contains the layer operations, so the number of layers is length(layers) + 1.
Conversion from a Flux.Chain is supported.
Layer operations
ControllerFormats.Architecture.AbstractLayerOp — Type
AbstractLayerOpAbstract type for layer operations.
Notes
An AbstractLayerOp represents a layer operation. A classical example is a "dense layer operation" with an affine map followed by an activation function.
The following non-standard methods are useful to implement:
ControllerFormats.Architecture.dim_in — Method
dim_in(L::AbstractLayerOp)Return the input dimension of a layer operation.
Input
L– layer operation
Output
The input dimension of L.
ControllerFormats.Architecture.dim_out — Method
dim_out(L::AbstractLayerOp)Return the output dimension of a layer operation.
Input
L– layer operation
Output
The output dimension of L.
ControllerFormats.Architecture.dim — Method
dim(L::AbstractLayerOp)Return the input and output dimension of a layer operation.
Input
N– neural network
Output
The pair $(i, o)$ where $i$ is the input dimension and $o$ is the output dimension of N.
Notes
This function is not exported due to name conflicts with other related packages.
More specific layer interfaces
ControllerFormats.Architecture.AbstractPoolingLayerOp — Type
AbstractPoolingLayerOp <: AbstractLayerOpAbstract type for pooling layer operations.
Notes
Pooling is an operation on a three-dimensional tensor that iterates over the first two dimensions in a window and aggregates the values, thus reducing the output dimension.
Implementation
The following (unexported) functions should be implemented:
window(::AbstractPoolingLayerOp)– return the pair $(p, q)$ representing the window sizeaggregation(::AbstractPoolingLayerOp)– return the aggregation function (applied to a tensor)
Implementation
ControllerFormats.Architecture.DenseLayerOp — Type
DenseLayerOp{F, M, B} <: AbstractLayerOpA dense layer operation is an affine map followed by an activation function.
Fields
weights– weight matrixbias– bias vectoractivation– activation function
Notes
Conversion from a Flux.Dense is supported.
ControllerFormats.Architecture.ConvolutionalLayerOp — Type
ConvolutionalLayerOp{F, M, B} <: AbstractLayerOpA convolutional layer operation is a series of filters, each of which computes a small affine map followed by an activation function.
Fields
weights– vector with one weight matrix for each filterbias– vector with one bias value for each filteractivation– activation function
Notes
Conversion from a Flux.Conv is supported.
ControllerFormats.Architecture.FlattenLayerOp — Type
FlattenLayerOp <: AbstractLayerOpA flattening layer operation converts a multidimensional tensor into a vector.
Notes
The implementation uses row-major ordering for convenience with the machine-learning literature.
julia> T = reshape([1, 3, 2, 4, 5, 7, 6, 8], (2, 2, 2))
2×2×2 Array{Int64, 3}:
[:, :, 1] =
1 2
3 4
[:, :, 2] =
5 6
7 8
julia> FlattenLayerOp()(T)
8-element Vector{Int64}:
1
2
3
4
5
6
7
8ControllerFormats.Architecture.MaxPoolingLayerOp — Type
MaxPoolingLayerOp <: AbstractPoolingLayerOpA max-pooling layer operation. The aggregation function is maximum.
Fields
p– horizontal window sizeq– vertical window size
ControllerFormats.Architecture.MeanPoolingLayerOp — Type
MeanPoolingLayerOp <: AbstractPoolingLayerOpA mean-pooling layer operation. The aggregation function is Statistics.mean.
Fields
p– horizontal window sizeq– vertical window size
Activation functions
ControllerFormats.Architecture.ActivationFunction — Type
ActivationFunctionAbstract type for activation functions.
ControllerFormats.Architecture.Id — Type
IdIdentity activation.
\[ f(x) = x\]
ControllerFormats.Architecture.ReLU — Type
ReLURectified linear unit (ReLU) activation.
\[ f(x) = max(x, 0)\]
ControllerFormats.Architecture.Sigmoid — Type
SigmoidSigmoid activation.
\[ f(x) = \frac{1}{1 + e^{-x}}\]
ControllerFormats.Architecture.Tanh — Type
TanhHyperbolic tangent activation.
\[ f(x) = tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}\]
ControllerFormats.Architecture.LeakyReLU — Type
LeakyReLU{N<:Number}Leaky ReLU activation.
\[ fₐ(x) = x > 0 ? x : a x\]
where $a$ is the parameter.
Fields
slope– parameter for negative inputs
The following strings can be parsed as activation functions:
ControllerFormats.FileFormats.available_activationsDict{String, ActivationFunction} with 12 entries:
"ReLU" => ReLU
"logsig" => Sigmoid
"relu" => ReLU
"Affine" => Id
"Sigmoid" => Sigmoid
"Id" => Id
"sigmoid" => Sigmoid
"σ" => Sigmoid
"Tanh" => Tanh
"linear" => Id
"tanh" => Tanh
"Linear" => Id