Transform Functions
simplegrad.functions.tranform.flatten(x: Tensor, start_dim: int = 0, end_dim: int = -1) -> Tensor
Flatten a range of dimensions into a single dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor. |
required |
start_dim
|
int
|
First dimension to flatten (inclusive). Supports negative indexing. |
0
|
end_dim
|
int
|
Last dimension to flatten (inclusive). Supports negative indexing. |
-1
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor with dimensions |
Source code in simplegrad/functions/tranform.py
simplegrad.functions.tranform.reshape(x: Tensor, new_shape: tuple[int, ...]) -> Tensor
Reshape a tensor to a new shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor. |
required |
new_shape
|
tuple[int, ...]
|
Target shape. Total number of elements must match. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor with values laid out in |