conv1d_transpose#

ivy.conv1d_transpose(x, filters, strides, padding, /, *, output_shape=None, filter_format='channel_last', data_format='NWC', dilations=1, bias=None, out=None)[source]#

Compute a 1-D transpose convolution given 3-D input x and filters arrays.

Parameters:
  • x (Union[Array, NativeArray]) – Input image [batch_size,w,d_in] or [batch_size,d_in,w].

  • filters (Union[Array, NativeArray]) – Convolution filters [fw,d_out,d_in].

  • strides (Union[int, Tuple[int]]) – The stride of the sliding window for each dimension of input.

  • padding (str) – Either ‘SAME’ (padding so that the output’s shape is the same as the input’s), or ‘VALID’ (padding so that the output’s shape is output_shape).

  • output_shape (Optional[Union[Shape, NativeShape]], default: None) – Shape of the output (Default value = None)

  • filter_format (str, default: 'channel_last') – Either “channel_first” or “channel_last”. “channel_first” corresponds to “IOW”,input data formats, while “channel_last” corresponds to “WOI”.

  • data_format (str, default: 'NWC') – The ordering of the dimensions in the input, one of “NWC” or “NCW”. “NWC” corresponds to input with shape (batch_size, width, channels), while “NCW” corresponds to input with shape (batch_size, channels, width).

  • dilations (Union[int, Tuple[int]], default: 1) – The dilation factor for each dimension of input. (Default value = 1)

  • bias (Optional[Array], default: None) – Bias array of shape [d_out].

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

  • ret – The result of the transpose convolution operation.

  • Both the description and the type hints above assumes an array input for simplicity,

  • but this function is nestable, and therefore also accepts ivy.Container

  • instances in place of any of the arguments.

Examples

With ivy.Array input:

>>> x = ivy.random_normal(mean=0, std=1, shape=[1, 28, 3])
>>> filters = ivy.random_normal(mean=0, std=1, shape=[3, 6, 3])
>>> y = ivy.conv1d_transpose(x, filters, 2, 'SAME')
>>> print(y.shape)
ivy.Shape(1, 56, 6)
>>> x = ivy.random_normal(mean=0, std=1, shape=[1, 128, 64])
>>> filters = ivy.random_normal(mean=0, std=1, shape=[1, 64, 64])
>>> ivy.conv1d_transpose(x, filters, 1, 'VALID', out=x)
>>> print(x.shape)
ivy.Shape(1, 128, 64)
>>> x = ivy.random_normal(mean=0, std=1, shape=[1, 256, 64])
>>> y = ivy.zeros((1, 258, 32))
>>> filters = ivy.random_normal(mean=0, std=1, shape=[3, 32, 64])
>>> ivy.conv1d_transpose(x, filters, 1, 'VALID', out=y)
>>> print(y.shape)
ivy.Shape(1, 258, 32)

With ivy.NativeArray input:

>>> x = ivy.native_array(
...         ivy.random_normal(mean=0, std=1, shape=[1, 256, 128]))
>>> filters = ivy.native_array(
...         ivy.random_normal(mean=0, std=1, shape=[3, 32, 128]))
>>> y = ivy.conv1d_transpose(x, filters, 2, 'SAME')
>>> print(y.shape)
ivy.Shape(1, 512, 32)

With one ivy.Container input:

>>> x = ivy.full((1, 6, 1), 2.7)
>>> a = ivy.random_normal(mean=0, std=1, shape=[3, 1, 1])
>>> b = ivy.random_normal(mean=0, std=1, shape=[3, 1, 1])
>>> filters = ivy.Container(a=a, b=b)
>>> y = ivy.conv1d_transpose(x, filters, 1, 'VALID', dilations=2)
>>> print(y.shape)
{
    a: ivy.Shape(1, 10, 1),
    b: ivy.Shape(1, 10, 1)
}

With multiple ivy.Container inputs:

>>> a = ivy.random_normal(mean=0, std=1, shape=[1, 14, 3])
>>> b = ivy.random_normal(mean=0, std=1, shape=[1, 28, 3])
>>> c = ivy.random_normal(mean=0, std=1, shape=[6, 3, 3])
>>> d = ivy.random_normal(mean=0, std=1, shape=[6, 3, 3])
>>> x = ivy.Container(a=a, b=b)
>>> filters = ivy.Container(c=c, d=d)
>>> y = ivy.conv1d_transpose(x, filters, 2, 'SAME')
>>> print(y.shape)
{
    a: {
        c: ivy.Shape(1, 28, 3),
        d: ivy.Shape(1, 28, 3)
    },
    b: {
        c: ivy.Shape(1, 56, 3),
        d: ivy.Shape(1, 56, 3)
    },
    c: {
        c: ivy.Shape(6, 6, 3),
        d: ivy.Shape(6, 6, 3)
    },
    d: {
        c: ivy.Shape(6, 6, 3),
        d: ivy.Shape(6, 6, 3)
    }
}
Array.conv1d_transpose(self, filters, strides, padding, /, *, output_shape=None, filter_format='channel_last', data_format='NWC', dilations=1, bias=None, out=None)[source]#

ivy.Array instance method variant of ivy.conv1d_transpose. This method simply wraps the function, and so the docstring for ivy.conv1d_transpose also applies to this method with minimal changes.

Parameters:
  • self (Array) – Input image [batch_size,w,d_in] or [batch_size,d_in,w].

  • filters (Union[Array, NativeArray]) – Convolution filters [fw,d_out,d_in].

  • strides (Union[int, Tuple[int]]) – The stride of the sliding window for each dimension of input.

  • padding (str) – either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.

  • output_shape (Optional[Union[Shape, NativeShape]], default: None) – Shape of the output (Default value = None)

  • filter_format (str, default: 'channel_last') – Either “channel_first” or “channel_last”. “channel_first” corresponds to “IOW”,input data formats, while “channel_last” corresponds to “WOI”.

  • data_format (str, default: 'NWC') – The ordering of the dimensions in the input, one of “NWC” or “NCW”. “NWC” corresponds to input with shape (batch_size, width, channels), while “NCW” corresponds to input with shape (batch_size, channels, width).

  • dilations (Union[int, Tuple[int]], default: 1) – The dilation factor for each dimension of input. (Default value = 1)

  • bias (Optional[Array], default: None) – Bias array of shape [d_out].

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The result of the transpose convolution operation.

Examples

>>> x = ivy.array([[[1., 2.], [3., 4.], [6., 7.], [9., 11.]]])  # NWC
>>> filters = ivy.array([[[0., 1.], [1., 1.]]])  # WIO (I == C)
>>> result = x.conv1d_transpose(filters, (1,), 'VALID')
>>> print(result)
ivy.array([[[ 2.,  3.],
...         [ 4.,  7.],
...         [ 7., 13.],
...         [11., 20.]]])
Container.conv1d_transpose(self, filters, strides, padding, /, *, output_shape=None, filter_format='channel_last', data_format='NWC', dilations=1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, bias=None, out=None)[source]#

ivy.Container instance method variant of ivy.conv1d_transpose. This method simply wraps the function, and so the docstring for ivy.conv1d_transpose also applies to this method with minimal changes.

Parameters:
  • self (Container) – Input image [batch_size,w,d_in] or [batch_size,d_in,w].

  • filters (Union[Array, NativeArray, Container]) – Convolution filters [fw,d_out,d_in].

  • strides (Union[int, Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.

  • output_shape (Optional[Union[Array, NativeArray, Container]], default: None) – Shape of the output (Default value = None)

  • filter_format (str, default: 'channel_last') – Either “channel_first” or “channel_last”. “channel_first” corresponds to “IOW”,input data formats, while “channel_last” corresponds to “WOI”.

  • data_format (str, default: 'NWC') – The ordering of the dimensions in the input, one of “NWC” or “NCW”. “NWC” corresponds to input with shape (batch_size, width, channels), while “NCW” corresponds to input with shape (batch_size, channels, width).

  • dilations (int, default: 1) – The dilation factor for each dimension of input. (Default value = 1)

  • key_chains (Optional[Union[List[str], Dict[str, str]]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (bool, default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (bool, default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (bool, default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • bias (Optional[Container], default: None) – Bias array of shape [d_out].

  • out (Optional[Union[Array, Container]], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Union[Array, NativeArray, Container]

Returns:

ret – The result of the transpose convolution operation.

Examples

>>> x = ivy.Container(a=ivy.random_normal(mean=0, std=1, shape=[1, 28, 3]),
...                   b=ivy.random_normal(mean=0, std=1, shape=[1, 56, 3]))
>>> filters = ivy.random_normal(mean=0, std=1, shape=[3, 6, 3])
>>> y = x.conv1d_transpose(filters, 2, 'SAME')
>>> print(y.shape)
{
    a: ivy.Shape(1, 56, 6),
    b: ivy.Shape(1, 112, 6)
}