Tensorex.map
You're seeing just the function
map
, go back to Tensorex module for more information.
Specs
Returns a tensor where each element is the result of invoking mapper
on each corresponding
element of the given tensor.
iex> Tensorex.map(Tensorex.from_list([[[ 0, 1, 2], [-3, -1, 1]],
...> [[-4, -2, 0], [ 1, 0, -1]]]), &(&1 * &1))
%Tensorex{data: %{ [0, 0, 1] => 1, [0, 0, 2] => 4, [0, 1, 0] => 9, [0, 1, 1] => 1, [0, 1, 2] => 1,
[1, 0, 0] => 16, [1, 0, 1] => 4, [1, 1, 0] => 1, [1, 1, 2] => 1}, shape: [2, 2, 3]}
iex> Tensorex.map(Tensorex.from_list([[[ 0, 1, 2], [-3, -1, 1]],
...> [[-4, -2, 0], [ 1, 0, -1]]]), &(&1 + 3))
%Tensorex{data: %{[0, 0, 0] => 3.0, [0, 0, 1] => 4, [0, 0, 2] => 5 , [0, 1, 1] => 2 , [0, 1, 2] => 4,
[1, 0, 0] => -1 , [1, 0, 1] => 1, [1, 0, 2] => 3.0, [1, 1, 0] => 4, [1, 1, 1] => 3.0, [1, 1, 2] => 2}, shape: [2, 2, 3]}
iex> Tensorex.map(Tensorex.from_list([[-3, -1, 1],
...> [-4, -2, 0],
...> [ 1, 0, -1]]),
...> fn
...> value, [index, index] -> value * value
...> value, _ -> value
...> end)
%Tensorex{data: %{[0, 0] => 9, [0, 1] => -1, [0, 2] => 1,
[1, 0] => -4, [1, 1] => 4,
[2, 0] => 1, [2, 2] => 1}, shape: [3, 3]}