MCPcopy Create free account
hub / github.com/apache/singa / flatten

Function flatten

python/singa/autograd.py:1426–1443  ·  view source on GitHub ↗

Flattens the input tensor into a 2D matrix. If input tensor has shape `(d_0, d_1, ... d_n)` then the output will have shape `(d_0 X d_1 ... d_(axis-1), d_axis X d_(axis+1) ... X dn)`. Args: x (Tensor): the input tensor axis (int): Indicate up to which input dimension

(x, axis=1)

Source from the content-addressed store, hash-verified

1424
1425
1426def flatten(x, axis=1):
1427 """
1428 Flattens the input tensor into a 2D matrix. If input tensor has shape
1429 `(d_0, d_1, ... d_n)` then the output will have shape `(d_0 X d_1 ...
1430 d_(axis-1), d_axis X d_(axis+1) ... X dn)`.
1431 Args:
1432 x (Tensor): the input tensor
1433 axis (int): Indicate up to which input dimensions (exclusive)
1434 should be flattened to the outer dimension of the output. The
1435 value for axis must be in the range [-r, r], where r is the
1436 rank of the input tensor. Negative value means counting
1437 dimensions from the back. When axis = 0, the shape of the
1438 output tensor is `(1, (d_0 X d_1 ... d_n)`, where the shape
1439 of the input tensor is `(d_0, d_1, ... d_n)`.
1440 Returns:
1441 the result Tensor
1442 """
1443 return Flatten(axis)(x)[0]
1444
1445
1446class ScatterElements(Operator):

Callers 1

__init__Method · 0.85

Calls 1

FlattenClass · 0.70

Tested by

no test coverage detected