Function convolution

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

Operation convolution (
  Operation features,
  Operation filters,
  ulong[] padding = [0LU, 0LU],
  ulong[] stride = [1LU, 1LU],
  string mod = __MODULE__,
  ulong line = cast(ulong)__LINE__
);

Currently this operation only implements 2D convolutions.

Parameters

NameDescription
features A tensor containing a batch of input feature maps.
filters A tensor containing the filters that will be convolved with the feature maps.

Returns

An operation representing convolutions of input imgs with some kernels.

Example

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().as!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
]);