MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / axis_order_scope

Function axis_order_scope

tensorflow/contrib/labeled_tensor/python/ops/core.py:807–837  ·  view source on GitHub ↗

Set axis order for the result of broadcasting operations within a scope. This allows you to ensure that tensors resulting from arithmetic have a predictable axis order. Example usage: with lt.axis_order_scope(['x', 'y', 'z']): # result is guaranteed to have the correct axis order

(axis_order=None)

Source from the content-addressed store, hash-verified

805@contextlib.contextmanager
806@tc.accepts(tc.Optional(tc.List(string_types)))
807def axis_order_scope(axis_order=None):
808 """Set axis order for the result of broadcasting operations within a scope.
809
810 This allows you to ensure that tensors resulting from arithmetic have a
811 predictable axis order.
812
813 Example usage:
814
815 with lt.axis_order_scope(['x', 'y', 'z']):
816 # result is guaranteed to have the correct axis order
817 result = w + b
818
819 You can nest scopes, in which case only the inner-most scope applies, e.g.,
820
821 with lt.axis_order(['x', 'y', 'z']):
822 with lt.axis_order():
823 result = w + b # uses the default (left-most) axis ordering
824
825 Args:
826 axis_order: optional list of strings providing axis names. By default,
827 creates a scope without axis order.
828
829 Yields:
830 The provided axis_order or `None`.
831 """
832 original_axis_order = get_axis_order()
833 _set_axis_order(axis_order)
834 try:
835 yield axis_order
836 finally:
837 _set_axis_order(original_axis_order)
838
839
840@tc.returns(tc.List(string_types))

Callers

nothing calls this directly

Calls 2

get_axis_orderFunction · 0.85
_set_axis_orderFunction · 0.85

Tested by

no test coverage detected