Tensorex.Operator.multiply
You're seeing just the function
multiply
, go back to Tensorex.Operator module for more information.
Specs
multiply(Tensorex.t() | number(), Tensorex.t() | number()) :: Tensorex.t()
Makes a product of tensors.
If both arguments are tensors, it returns a tensor product of them. When one of arguments is a
number/0
, then all elements of the tensor will be amplified by the scalar.
iex> Tensorex.Operator.multiply(
...> Tensorex.from_list([2, 5.2, -4 , 0 ]),
...> Tensorex.from_list([2, 3.5, -1.6, 8.2]))
%Tensorex{data: %{[0, 0] => 4 , [0, 1] => 7.0, [0, 2] => -3.2 , [0, 3] => 16.4 ,
[1, 0] => 10.4, [1, 1] => 18.2, [1, 2] => -8.32, [1, 3] => 42.64,
[2, 0] => -8 , [2, 1] => -14.0, [2, 2] => 6.4 , [2, 3] => -32.8}, shape: [4, 4]}
iex> Tensorex.Operator.multiply(3.5,
...> Tensorex.from_list([[2 , 3.5, -1.5, 8.0],
...> [4.12, -2 , 1 , 0 ]]))
%Tensorex{data: %{[0, 0] => 7.0 , [0, 1] => 12.25, [0, 2] => -5.25, [0, 3] => 28.0,
[1, 0] => 14.42, [1, 1] => -7.0 , [1, 2] => 3.5 }, shape: [2, 4]}
Specs
multiply(Tensorex.t(), Tensorex.t(), [{non_neg_integer(), non_neg_integer()}]) :: Tensorex.t() | number()
Makes a dot product of tensors.
Components specified by the axes
will be sumed up (or contracted).
iex> Tensorex.Operator.multiply(
...> Tensorex.from_list([0, 0.0, 0.0, 0 ]),
...> Tensorex.from_list([2, 3.5, -1.6, 8.2]), [{0, 0}])
0.0
iex> Tensorex.Operator.multiply(
...> Tensorex.from_list([[2 , 3.5, -1.6, 8.2],
...> [1.1, 3.0, 8 , -12.1]]),
...> Tensorex.from_list([[0 , 0.0],
...> [0.0, 0 ],
...> [0.0, 0 ],
...> [0 , 0 ]]), [{0, 1}, {1, 0}])
0.0
iex> Tensorex.Operator.multiply(
...> Tensorex.from_list([2, 5.2, -4 , 0 ]),
...> Tensorex.from_list([2, 3.5, -1.6, 8.2]), [{0, 0}])
28.6
iex> Tensorex.Operator.multiply(
...> Tensorex.from_list([[ 2 , 5.5, -4 , 0 ],
...> [ 4.12, -2 , 1 , 0 ]]),
...> Tensorex.from_list([[ 2 , 3.5],
...> [-1.6 , 8.2],
...> [ 2 , -3.5],
...> [-1.5 , 8.0]]), [{0, 1}])
%Tensorex{data: %{[0, 0] => 18.42, [0, 1] => 30.584, [0, 2] => -10.42, [0, 3] => 29.96,
[1, 0] => 4.0 , [1, 1] => -25.2 , [1, 2] => 18.0 , [1, 3] => -24.25,
[2, 0] => -4.5 , [2, 1] => 14.6 , [2, 2] => -11.5 , [2, 3] => 14.0 }, shape: [4, 4]}