module Bottle::Assemble

Extended Modules

Direct including types

Defined in:

arrayops/build.cr

Instance Method Summary

Instance Method Detail

def column_stack(alist : Array(BaseArray(U))) forall U #

[View source]
def concatenate(alist : Array(BaseArray(U)), axis : Int32) forall U #

Concatenates an array of Tensor's along a provided axis.

Parameters

alist : Array(Tensor)

  • Array containing Tensors to be concatenated axis : Int32
  • Axis for concatentation, must be an existing axis present in all Tensors, and all Tensors must have the same shape off-axis

Returns

ret : Tensor

  • Result of the concatenation

Examples

t = Tensor.new([2, 2, 3]) { |i| i }

concatenate([t, t, t], axis=-1)

Tensor([[[ 0,  1,  2,  0,  1,  2,  0,  1,  2],
         [ 3,  4,  5,  3,  4,  5,  3,  4,  5]],

        [[ 6,  7,  8,  6,  7,  8,  6,  7,  8],
         [ 9, 10, 11,  9, 10, 11,  9, 10, 11]]])

[View source]
def dstack(alist : Array(BaseArray(U))) forall U #

[View source]
def hstack(alist : Array(BaseArray(U))) forall U #

Concatenates a list of Tensors along axis 1

Parameters

alist : Array(Tensor)

  • Array containing Tensors to be stacked

Returns

ret : Tensor

  • Result of the concatenation

Examples

t = Tensor.new([2, 2, 3])
hstack([t, t, t])

Tensor([[[ 0,  1,  2],
         [ 3,  4,  5],
         [ 0,  1,  2],
         [ 3,  4,  5],
         [ 0,  1,  2],
         [ 3,  4,  5]],

        [[ 6,  7,  8],
         [ 9, 10, 11],
         [ 6,  7,  8],
         [ 9, 10, 11],
         [ 6,  7,  8],
         [ 9, 10, 11]]])

[View source]
def vstack(alist : Array(BaseArray(U))) forall U #

Concatenates a list of Tensors along axis 0

Parameters

alist : Array(Tensor)

  • Array containing Tensors to be stacked

Returns

ret : Tensor

  • Result of the concatenation

Examples

t = Tensor.new([2, 2, 3])
vstack([t, t, t])

Tensor([[[ 0,  1,  2],
         [ 3,  4,  5]],

        [[ 6,  7,  8],
         [ 9, 10, 11]],

        [[ 0,  1,  2],
         [ 3,  4,  5]],

        [[ 6,  7,  8],
         [ 9, 10, 11]],

        [[ 0,  1,  2],
         [ 3,  4,  5]],

        [[ 6,  7,  8],
         [ 9, 10, 11]]])

[View source]