The convolution of a weight kernel over an image, the shared-weight operation at the heart of a convolutional network.
Usage
morie_conv2d(image, kernel, bias = 0, stride = 1, activation = NULL)
Arguments
- image
numeric array, height x width or height x width x channels
- kernel
numeric weight array with the same channel depth
- bias
scalar bias added to every receptive field
- stride
step between receptive fields
- activation
optional activation, "relu" or "logistic"
Value
A list holding the fitted quantities for the method called: point
estimates, fitted values and any diagnostics it produces. See the
individual method descriptions above for the components each returns.
Details
These functions mirror, in R, the implementations in the Python package
morie; the two are checked against each other by the parity
tests in tests/testthat/.
Examples
img <- matrix(1:16, 4, 4)
k <- matrix(c(1, 0, 0, -1), 2, 2)
morie_conv2d(img, k)
#> $feature_map
#> [,1] [,2] [,3]
#> [1,] -5 -5 -5
#> [2,] -5 -5 -5
#> [3,] -5 -5 -5
#>
#> $output_shape
#> [1] 3 3
#>
#> $n_parameters
#> [1] 5
#>