nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.DeepLearning / CNNLayers

CNNLayers

Full name Microsoft.VisualBasic.MachineLearning.CNN.CNNLayers Assembly Microsoft.VisualBasic.DeepLearning Members 17

Factory functions for building the layer specifications of a CNN network.

00 Remarks

The function names correspond one to one with the MLkit of R# (studio\Rsharp_kit\MLkit\MachineLearning\CNN.vb), so a network definition written in an R# script can be translated line by line into VB. Taking tutorials\..\CNN_image\auto_encoder.R as an example:

 ' R#:
 let cnn = cnn()
     + input_layer([28, 28], 1)
     + conv_layer(5, 32, 1, 2)
     + pool_layer(2, 2, 0)
     + leaky_relu_layer()
     + softmax_layer();

 ' VB:
 Dim cnn = New LayerBuilder() +
     input_layer({28, 28}, 1) +
     conv_layer(5, 32, 1, 2) +
     pool_layer(2, 2, 0) +
     leaky_relu_layer() +
     softmax_layer()
 

The only difference is that VB requires the binary operator at the end of the previous line for an implicit line continuation, whereas R# allows it at the start of the next line.

These functions all return CNNLayerArguments objects (layers that have not been created yet). The LayerBuilder + operator instantiates them from left to right, so the resulting layer sequence is identical to calling buildXxxLayer for every layer individually.

01 Syntax

Microsoft.VisualBasic.MachineLearning.CNN.CNNLayers

02 Methods

NameOverloadsSummary
spec 1 构造规格对象;name 只用于 CNNLayerArguments.ToString() 的可读输出
input_layer 2 Input layer variant that takes the image size directly as a Dimension.
conv_layer 1 Convolution layer: extracts local features (edges, textures and so on) with a bank of filters.
conv_transpose_layer 1 Transposed convolution layer: upsamples a feature map back to a larger spatial size (decoder side of an auto encoder, semantic segmentation, and similar scenarios).
pool_layer 1 Pooling layer: downsamples the feature map inside a sliding window.
full_connected_layer 1 Fully connected layer: every neuron is connected to the complete output of the previous layer.
relu_layer 1 ReLU activation: f(x) = max(0, x).
leaky_relu_layer 1 LeakyReLU activation: keeps a small slope on the negative half axis so neurons do not "die".
sigmoid_layer 1 Sigmoid activation: f(x) = 1 / (1 + exp(-x)), with output in (0, 1).
tanh_layer 1 Tanh activation: output in (-1, 1).
maxout_layer 1 Maxout activation: takes the maximum value inside each group.
gaussian_layer 1 Gaussian activation layer.
lrn_layer 1 Local response normalization (LRN): lateral inhibition around strongly responding neurons increases the contrast of high frequency features.
dropout_layer 1 Dropout layer: randomly drops a fraction of the activations during training to reduce overfitting.
softmax_layer 1 Softmax: turns the activations into a probability distribution in [0, 1] (multi-class output layer).
regression_layer 1 Regression loss layer: the loss used for continuous outputs (auto encoders, variational auto encoders).

03 Members

method spec #
spec(String, Func(Of LayerBuilder, LayerBuilder))

构造规格对象;name 只用于 CNNLayerArguments.ToString() 的可读输出

method input_layer overload 2 #
input_layer(Int32(), Int32)

Input layer: passes the data into the network and declares the image size and channel count.

Parameters
NameTypeDescription
sizeInt32()

The image size, given as {width, height}.

depthInt32

Number of channels; 1 for grayscale images.

Returns

The input layer specification.

method input_layer #
input_layer(Dimension, Int32)

Input layer variant that takes the image size directly as a Dimension.

Parameters
NameTypeDescription
dimsDimension

The image size.

depthInt32

Number of channels; 1 for grayscale images.

Returns

The input layer specification.

method conv_layer #
conv_layer(Int32, Int32, Int32, Int32)

Convolution layer: extracts local features (edges, textures and so on) with a bank of filters.

Parameters
NameTypeDescription
sxInt32

Side length of the (square) filter window.

filtersInt32

Number of filters, i.e. the number of output channels.

strideInt32

Sliding step of the filter window.

paddingInt32

Width of the zero padding applied to the input.

Returns

The convolution layer specification.

method conv_transpose_layer #
conv_transpose_layer(Int32(), Int32(), Int32, Int32)

Transposed convolution layer: upsamples a feature map back to a larger spatial size (decoder side of an auto encoder, semantic segmentation, and similar scenarios).

Parameters
NameTypeDescription
dimsInt32()

Target output size {width, height, depth}.

filterInt32()

Filter window {width, height}.

filtersInt32

Number of filters.

strideInt32

Stride.

Returns

The transposed convolution layer specification.

method pool_layer #
pool_layer(Int32, Int32, Int32)

Pooling layer: downsamples the feature map inside a sliding window.

Parameters
NameTypeDescription
sxInt32

Side length of the (square) pooling window.

strideInt32

Stride of the pooling window.

paddingInt32

Width of the zero padding applied to the input.

Returns

The pooling layer specification.

method full_connected_layer #
full_connected_layer(Int32)

Fully connected layer: every neuron is connected to the complete output of the previous layer.

Parameters
NameTypeDescription
sizeInt32

Number of neurons.

Returns

The fully connected layer specification.

method relu_layer #
relu_layer

ReLU activation: f(x) = max(0, x).

Returns

The ReLU layer specification.

method leaky_relu_layer #
leaky_relu_layer

LeakyReLU activation: keeps a small slope on the negative half axis so neurons do not "die".

Returns

The LeakyReLU layer specification.

method sigmoid_layer #
sigmoid_layer

Sigmoid activation: f(x) = 1 / (1 + exp(-x)), with output in (0, 1).

Returns

The sigmoid layer specification.

method tanh_layer #
tanh_layer

Tanh activation: output in (-1, 1).

Returns

The tanh layer specification.

method maxout_layer #
maxout_layer

Maxout activation: takes the maximum value inside each group.

Returns

The maxout layer specification.

method gaussian_layer #
gaussian_layer

Gaussian activation layer.

Returns

The Gaussian layer specification.

method lrn_layer #
lrn_layer(Int32)

Local response normalization (LRN): lateral inhibition around strongly responding neurons increases the contrast of high frequency features.

Parameters
NameTypeDescription
nInt32

Size of the neighborhood involved in the normalization.

Returns

The LRN layer specification.

method dropout_layer #
dropout_layer(Double)

Dropout layer: randomly drops a fraction of the activations during training to reduce overfitting.

Parameters
NameTypeDescription
drop_probDouble

Probability of dropping an activation.

Returns

The dropout layer specification.

method softmax_layer #
softmax_layer

Softmax: turns the activations into a probability distribution in [0, 1] (multi-class output layer).

Returns

The softmax layer specification.

method regression_layer #
regression_layer

Regression loss layer: the loss used for continuous outputs (auto encoders, variational auto encoders).

Returns

The regression layer specification.