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

Method shape

tensorflow/python/framework/ops.py:427–472  ·  view source on GitHub ↗

Returns the `TensorShape` that represents the shape of this tensor. The shape is computed using shape inference functions that are registered in the Op for each `Operation`. See `tf.TensorShape` for more details of what a shape represents. The inferred shape of a tensor is use

(self)

Source from the content-addressed store, hash-verified

425
426 @property
427 def shape(self):
428 """Returns the `TensorShape` that represents the shape of this tensor.
429
430 The shape is computed using shape inference functions that are
431 registered in the Op for each `Operation`. See
432 `tf.TensorShape`
433 for more details of what a shape represents.
434
435 The inferred shape of a tensor is used to provide shape
436 information without having to launch the graph in a session. This
437 can be used for debugging, and providing early error messages. For
438 example:
439
440 ```python
441 c = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
442
443 print(c.shape)
444 ==> TensorShape([Dimension(2), Dimension(3)])
445
446 d = tf.constant([[1.0, 0.0], [0.0, 1.0], [1.0, 0.0], [0.0, 1.0]])
447
448 print(d.shape)
449 ==> TensorShape([Dimension(4), Dimension(2)])
450
451 # Raises a ValueError, because `c` and `d` do not have compatible
452 # inner dimensions.
453 e = tf.matmul(c, d)
454
455 f = tf.matmul(c, d, transpose_a=True, transpose_b=True)
456
457 print(f.shape)
458 ==> TensorShape([Dimension(3), Dimension(4)])
459 ```
460
461 In some cases, the inferred shape may have unknown dimensions. If
462 the caller has additional information about the values of these
463 dimensions, `Tensor.set_shape()` can be used to augment the
464 inferred shape.
465
466 Returns:
467 A `TensorShape` representing the shape of this tensor.
468
469 """
470 if self._shape_val is None:
471 self._shape_val = self._c_api_shape()
472 return self._shape_val
473
474 def _get_input_ops_without_shapes(self, target_op):
475 """Returns ops needing shape inference to compute target_op's shape."""

Callers 15

__init__Method · 0.45
_attentionMethod · 0.45
_multihead_attentionMethod · 0.45
_bst_towerMethod · 0.45
_dot_opMethod · 0.45
__init__Method · 0.45
_auxiliary_lossMethod · 0.45
_attentionMethod · 0.45
callMethod · 0.45
attentionFunction · 0.45
din_attentionFunction · 0.45
din_fcn_attentionFunction · 0.45

Calls 1

_c_api_shapeMethod · 0.95

Tested by 15

TestSetNodeTensorAttrMethod · 0.36
TestSimplePlaceholderMethod · 0.36
_writeDummySavedModelMethod · 0.36
FooMethod · 0.36
testShapeMethod · 0.36
testShapeMethod · 0.36
test_degenerate_shapeMethod · 0.36