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

Method set_tuple_shapes

tensorflow/python/tpu/tpu_feed.py:260–295  ·  view source on GitHub ↗

Sets the shape of each element of the queue. tuple_shapes must be a list of length self.number_of_tuple_elements, and each element must be convertible to a TensorShape. Args: tuple_shapes: the shapes of each queue element. Raises: ValueError: if tuple_shapes is not

(self, tuple_shapes)

Source from the content-addressed store, hash-verified

258 return self._tuple_shapes
259
260 def set_tuple_shapes(self, tuple_shapes):
261 """Sets the shape of each element of the queue.
262
263 tuple_shapes must be a list of length
264 self.number_of_tuple_elements, and each element must be
265 convertible to a TensorShape.
266
267 Args:
268 tuple_shapes: the shapes of each queue element.
269
270 Raises:
271 ValueError: if tuple_shapes is not of length
272 self.number_of_tuple_elements.
273 TypeError: if an element of tuple_shapes cannot be converted to
274 a TensorShape.
275 """
276 if len(tuple_shapes) != self.number_of_tuple_elements:
277 raise ValueError("tuple_shapes is %s, but must be a list of length %d" %
278 (str(tuple_shapes), self.number_of_tuple_elements))
279 try:
280 tuple_shapes = [tensor_shape.as_shape(shape) for shape in tuple_shapes]
281 except (ValueError, TypeError) as e:
282 raise TypeError(
283 "tuple_shapes is %s, but must be a list of elements each "
284 "convertible to TensorShape: got error %s" % (str(tuple_shapes),
285 str(e)))
286 if self._frozen:
287 for (frozen, updated) in zip(self._tuple_shapes, tuple_shapes):
288 if frozen != updated:
289 raise ValueError(
290 "Trying to update InfeedQueue with frozen configuration with an "
291 "incompatible shape. Frozen shapes are %s, updated shapes are %s"
292 % (str(self._tuple_shapes), str(tuple_shapes)))
293 else:
294 self._tuple_shapes = tuple_shapes
295 self._validate()
296
297 @property
298 def sharding_policies(self):

Callers 5

__init__Method · 0.95
testModificationMethod · 0.95
testFreezingMethod · 0.95

Calls 1

_validateMethod · 0.95

Tested by 2

testModificationMethod · 0.76
testFreezingMethod · 0.76