convolution

Creates a convolution operation that performs the computation required to implement a convolutional layer.

Currently this operation only implements 2D convolutions.

convolution
(,,
size_t[] padding = [0, 0]
,
size_t[] stride = [1, 1]
,
string mod = __MODULE__
,
size_t line = __LINE__
)

Parameters

features Operation

A tensor containing a batch of input feature maps.

filters Operation

A tensor containing the filters that will be convolved with the feature maps.

Return Value

Type: Operation

An operation representing convolutions of input imgs with some kernels.

Examples

import dopt.core : evaluate;

auto features = float32([1, 1, 3, 5], [
    1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
    1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
    1.0f, 1.0f, 1.0f, 0.0f, 0.0f
]);

auto filters = float32([1, 1, 1, 2], [
    -1.0f, 1.0f
]);

auto result = convolution(features, filters);

auto edges = result.evaluate().get!float;

assert(edges == [
    0.0f, 0.0f, 1.0f, 0.0f,
    0.0f, 0.0f, 1.0f, 0.0f,
    0.0f, 0.0f, 1.0f, 0.0f
]);

Meta