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

Class Axis

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

Size and label information for an axis. Axis contains either a tf.compat.v1.Dimension indicating the size of an axis, or a tuple of tick labels for the axis. If tick labels are provided, they must be unique.

Source from the content-addressed store, hash-verified

62
63
64class Axis(object):
65 """Size and label information for an axis.
66
67 Axis contains either a tf.compat.v1.Dimension indicating the size of an axis,
68 or a tuple of tick labels for the axis.
69
70 If tick labels are provided, they must be unique.
71 """
72
73 @tc.accepts(object, string_types, AxisValue)
74 def __init__(self, name, value):
75 """Construct an Axis.
76
77 Args:
78 name: Name of the axis.
79 value: Either None, an int or tf.compat.v1.Dimension giving the size of
80 the axis, or a sequence that is not a string additionally providing
81 coordinate (tick) labels.
82
83 Raises:
84 ValueError: If the user provides labels with duplicate values.
85 """
86 if isinstance(value, tensor_shape.Dimension):
87 dimension = value
88 labels = None
89 elif isinstance(value, int) or value is None:
90 dimension = tensor_shape.Dimension(value)
91 labels = None
92 else:
93 dimension = tensor_shape.Dimension(len(value))
94 labels = tuple(value)
95
96 if dimension.value == 0:
97 # Treat a zero-length axis as if it has labels.
98 labels = ()
99
100 if labels is not None:
101 index = dict(zip(labels, range(len(labels))))
102 if len(index) != len(labels):
103 raise ValueError(
104 'Tick labels must be unique, but got {}'.format(labels))
105 else:
106 index = None
107
108 self._name = name # type: string_types
109 self._dimension = dimension # type: tensor_shape.Dimension
110 self._labels = labels # type: Optional[tuple]
111 self._index = index # type: Optional[Dict[Any, int]]
112
113 @property
114 @tc.returns(string_types)
115 def name(self):
116 return self._name
117
118 @tc.returns(string_types)
119 def __repr__(self):
120 # Axis('x', Dimension(2))
121 # TODO(shoyer): make very long reprs more succint?

Callers 11

as_axisFunction · 0.70
concat_axesFunction · 0.70
GetPackNodeDefFunction · 0.50
TEST_FFunction · 0.50
TEST_FFunction · 0.50
TEST_FFunction · 0.50
PackGradFunction · 0.50
UnpackGradFunction · 0.50
TESTFunction · 0.50

Calls

no outgoing calls

Tested by 5

GetPackNodeDefFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TESTFunction · 0.40