gyoza.utilities package
Submodules
gyoza.utilities.tensors module
- gyoza.utilities.tensors.expand_axes(x: Tensor, axes) Tensor[source]
Expands x with singleton axes.
- Parameters:
x (
tensorflow.Tensor) – The tensor to be expanded.axes (
List[tensorflow.Tensor]) – The axes along which to expand. Their indices are assumed to be valid in the shape ofx_new. This means if, e.g.xhas two axes thenaxesmay be, e.g. [0,1,3,5,6,7] where axes 2 and 4 are filled in order byxbutaxesmust not be, e.g. [0,1,3,5,6,10] because of the gap between 6 and 10 that would be introduced in the shape ofx_new.
- Returns:
x_new (
tensorflow.Tensor) - The reshaped version of x with singletons along ‘’axes’’.
- gyoza.utilities.tensors.flatten_along_axes(x: Tensor, axes: List[int]) Tensor[source]
Flattens an input
xalong axesaxes.- Parameters:
x (
tensorflow.Tensor) – The input to be flattened. Assumed to have at least as many axes as indicated byaxes.axes (
List[int]) – The axes along which the input shall be flattened.
- Returns:
x_new (
tensorflow.Tensor) - The reshaped tensorxflattened alongaxes.
- gyoza.utilities.tensors.move_axis(x: Tensor, from_index: int, to_index: int) Tensor[source]
Moves an axis from from_index to to_index.
- Parameters:
x (
tensorflow.Tensor) – A tensor of shape […, k, …] where k is at from_index.from_index (int) – The index of the axis before transposition.
to_index (int) – The index of the axis after transposition.
- Returns:
x_new (
tensorflow.Tensor): The tensor x transposed such that shape […, k, …] now has k at to_index.
- gyoza.utilities.tensors.swop_axes(x: Tensor, from_axis: int, to_axis: int) Tensor[source]
Swops axes of
x.- Parameters:
x (
tensorflow.Tensor) – The input whose axes shall be swopped. Assumed to have at least as many axes as indicated byfrom_axisandto_axis.from_axis (int) – The axes to be swopped with
to_axis.to_axis (int) – The axes to be swopped with
from_axis.
- Returns:
x_new (
tensorflow.Tensor) - The input whichfrom_axisandto_axisswopped.