conv: Create a convolutional layer

View source: R/layers.R

convR Documentation

Create a convolutional layer

Description

Wrapper for a convolutional layer. The dimensions of the convolution operation are inferred from the shape of the input data. This shape must follow the pattern (batch_shape, x, [y, [z, ]], channel) where dimensions y and z are optional, and channel will be either 1 for grayscale images or generally 3 for colored ones.

Usage

conv(
  filters,
  kernel_size,
  padding = "same",
  max_pooling = NULL,
  average_pooling = NULL,
  upsampling = NULL,
  activation = "linear"
)

Arguments

filters

Number of filters learned by the layer

kernel_size

Integer or list of integers indicating the size of the weight matrices to be convolved with the image

padding

One of "valid" or "same" (case-insensitive). See layer_conv_2d for more details

max_pooling

NULL or an integer indicating the reduction ratio for a max pooling operation after the convolution

average_pooling

NULL or an integer indicating the reduction ratio for an average pooling operation after the convolution

upsampling

NULL or an integer indicating the augmentation ratio for an upsampling operation after the convolution

activation

Optional, string indicating activation function (linear by default)

Value

A construct with class "ruta_network"

See Also

Other neural layers: dense(), dropout(), input(), layer_keras(), output(), variational_block()

Examples

# Sample convolutional autoencoder
net <- input() +
 conv(16, 3, max_pooling = 2, activation = "relu") +
 conv(8, 3, max_pooling = 2, activation = "relu") +
 conv(8, 3, upsampling = 2, activation = "relu") +
 conv(16, 3, upsampling = 2, activation = "relu") +
 conv(1, 3, activation = "sigmoid")

ruta documentation built on Jan. 9, 2023, 1:20 a.m.