@frozen
public struct Conv1D<Scalar> : Layer where Scalar : TensorFlowFloatingPoint
A 1-D convolution layer (e.g. temporal convolution over a time-series).
This layer creates a convolution filter that is convolved with the layer input to produce a tensor of outputs.
-
The 3-D convolution filter.
Declaration
public var filter: Tensor<Scalar>
-
The bias vector.
Declaration
public var bias: Tensor<Scalar>
-
The element-wise activation function.
Declaration
@noDerivative public let activation: Activation
-
The stride of the sliding window for the temporal dimension.
Declaration
@noDerivative public let stride: Int
-
The padding algorithm for convolution.
Declaration
@noDerivative public let padding: Padding
-
The dilation factor for the temporal dimension.
Declaration
@noDerivative public let dilation: Int
-
Creates a
Conv1D
layer with the specified filter, bias, activation function, stride, dilation and padding.Declaration
public init( filter: Tensor<Scalar>, bias: Tensor<Scalar>? = nil, activation: @escaping Activation = identity, stride: Int = 1, padding: Padding = .valid, dilation: Int = 1 )
Parameters
filter
The 3-D convolution filter of shape [filter width, input channel count, output channel count].
bias
The bias vector of shape [output channel count].
activation
The element-wise activation function.
stride
The stride of the sliding window for the temporal dimension.
padding
The padding algorithm for convolution.
dilation
The dilation factor for the temporal dimension.
-
Returns the output obtained from applying the layer to the given input.
The output width is computed as:
output width = (input width + 2 * padding size - (dilation * (filter width - 1) + 1)) / stride + 1
and padding size is determined by the padding scheme.
Note
Padding size equals zero when using
.valid
.Parameters
input
The input to the layer [batch size, input width, input channel count].
Return Value
The output of shape [batch size, output width, output channel count].
-
Creates a
Conv1D
layer with the specified filter shape, stride, padding, dilation and element-wise activation function.Declaration
public init( filterShape: (Int, Int, Int), stride: Int = 1, padding: Padding = .valid, dilation: Int = 1, activation: @escaping Activation = identity, useBias: Bool = true, filterInitializer: ParameterInitializer<Scalar> = glorotUniform(), biasInitializer: ParameterInitializer<Scalar> = zeros() )
Parameters
filterShape
The 3-D shape of the filter, representing (filter width, input channel count, output channel count).
stride
The stride of the sliding window for the temporal dimension.
padding
The padding algorithm for convolution.
dilation
The dilation factor for the temporal dimension.
activation
The element-wise activation function.
filterInitializer
Initializer to use for the filter parameters.
biasInitializer
Initializer to use for the bias parameters.