import numpy as np
from .operation import Operation
from .op_reshape import OpReshape
[docs]class OpFlatten(OpReshape):
"""Flatten the tensor to 1-D array."""
[docs] def __init__(self, x: Operation, **kwargs):
super(OpFlatten, self).__init__(x, shape=(int(np.prod(x.shape)),), **kwargs)
[docs] def _get_name(self) -> str:
return 'flatten(%s)' % self.inputs[0].name
[docs] def _get_op_name(self) -> str:
return 'flatten(%s)' % self.inputs[0]._op_name