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

Function reshape

tensorflow/python/keras/backend.py:2598–2623  ·  view source on GitHub ↗

Reshapes a tensor to the specified shape. Arguments: x: Tensor or variable. shape: Target shape tuple. Returns: A tensor. Example: ```python >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) >>> a <tf.Tensor: id=32, shape=(4, 3), dtype=in

(x, shape)

Source from the content-addressed store, hash-verified

2596
2597@keras_export('keras.backend.reshape')
2598def reshape(x, shape):
2599 """Reshapes a tensor to the specified shape.
2600
2601 Arguments:
2602 x: Tensor or variable.
2603 shape: Target shape tuple.
2604
2605 Returns:
2606 A tensor.
2607
2608 Example:
2609 ```python
2610 >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
2611 >>> a
2612 <tf.Tensor: id=32, shape=(4, 3), dtype=int32, numpy=
2613 array([[ 1, 2, 3],
2614 [ 4, 5, 6],
2615 [ 7, 8, 9],
2616 [10, 11, 12]], dtype=int32)>
2617 >>> tf.keras.backend.reshape(a, shape=(2, 6))
2618 <tf.Tensor: id=35, shape=(2, 6), dtype=int32, numpy=
2619 array([[ 1, 2, 3, 4, 5, 6],
2620 [ 7, 8, 9, 10, 11, 12]], dtype=int32)>
2621 ```
2622 """
2623 return array_ops.reshape(x, shape)
2624
2625
2626@keras_export('keras.backend.permute_dimensions')

Callers 2

local_convFunction · 0.70
bias_addFunction · 0.70

Calls 1

reshapeMethod · 0.80

Tested by

no test coverage detected