Skip to content

tensorop

TensorOp

Bases: Op

An Operator class which takes and returns tensor data.

These Operators are used in fe.Network to perform graph-based operations like neural network training.

Source code in fastestimator\fastestimator\op\tensorop\tensorop.py
class TensorOp(Op):
    """An Operator class which takes and returns tensor data.

    These Operators are used in fe.Network to perform graph-based operations like neural network training.
    """
    def forward(self, data: Union[Tensor, List[Tensor]], state: Dict[str, Any]) -> Union[Tensor, List[Tensor]]:
        """A method which will be invoked in order to transform data.

        This method will be invoked on batches of data.

        Args:
            data: The batch from the data dictionary corresponding to whatever keys this Op declares as its `inputs`.
            state: Information about the current execution context, for example {"mode": "train"}.

        Returns:
            The `data` after applying whatever transform this Op is responsible for. It will be written into the data
            dictionary based on whatever keys this Op declares as its `outputs`.
        """
        return data

forward

A method which will be invoked in order to transform data.

This method will be invoked on batches of data.

Parameters:

Name Type Description Default
data Union[Tensor, List[Tensor]]

The batch from the data dictionary corresponding to whatever keys this Op declares as its inputs.

required
state Dict[str, Any]

Information about the current execution context, for example {"mode": "train"}.

required

Returns:

Type Description
Union[Tensor, List[Tensor]]

The data after applying whatever transform this Op is responsible for. It will be written into the data

Union[Tensor, List[Tensor]]

dictionary based on whatever keys this Op declares as its outputs.

Source code in fastestimator\fastestimator\op\tensorop\tensorop.py
def forward(self, data: Union[Tensor, List[Tensor]], state: Dict[str, Any]) -> Union[Tensor, List[Tensor]]:
    """A method which will be invoked in order to transform data.

    This method will be invoked on batches of data.

    Args:
        data: The batch from the data dictionary corresponding to whatever keys this Op declares as its `inputs`.
        state: Information about the current execution context, for example {"mode": "train"}.

    Returns:
        The `data` after applying whatever transform this Op is responsible for. It will be written into the data
        dictionary based on whatever keys this Op declares as its `outputs`.
    """
    return data