Esempio n. 1
0
    def _check_input(self) -> None:
        """Assert the input input tensor is 4 dimensional."""

        check_tensor(self.x, shape_dim=4)

        if self.x.shape[1] < self.height:
            raise (
                f"{self.name}: Input heights must be higher or equal to filter heights."
                f"Input heights {self.x.shape[1]}, filter heights {self.height}"
            )

        if self.x.shape[2] < self.width:
            raise (
                f"{self.name}: Input heights must be higher or equal to filter heights."
                f"Input heights {self.x.shape[2]}, filter heights {self.width}"
            )
Esempio n. 2
0
    def check_input(self) -> None:
        """Check all input tensor types"""

        check_tensor(self.y)
        check_tensor(self.x_out)
        [check_variable(w) for w in self.weights]
Esempio n. 3
0
    def _check_input(self) -> None:
        """Assert the input input tensor is 2 dimensional."""

        check_tensor(self.x, shape_dim=2)
Esempio n. 4
0
    def _check_input(self) -> None:
        """Check if both input respect all dimension conditions."""

        check_tensor(self.x, shape_dim=4)
        check_tensor(self.x_lag, shape_dim=4)

        if self.x.shape[3] < self.x_lag.shape[3]:
            raise TypeError(
                f"{self.name}: x must have a number of channel higher or equal than x_lag. "
                f"Channel for x is {self.x.shape[3].value} whereas is {self.x_lag.shape[3].value} "
                "for x_lag.")

        if self.x.shape[1] > self.x_lag.shape[1]:
            raise TypeError(
                f"{self.name}: x must have a height lower or equal than x_lag. "
                f"Height for x is {self.x.shape[1].value} whereas is {self.x_lag.shape[1].value}"
                " for x_lag.")

        elif self.x.shape[1] < self.x_lag.shape[1]:
            if any([
                    x is None for x in
                [self.pool.height, self.pool.stride, self.pool.padding]
            ]):
                raise TypeError(
                    "x_lag reduction needed. You must feed value for height, stride and padding. "
                )
            dilation = 0 if self.pool.dilation is None else self.pool.dilation[
                0]
            new_dim = get_dim_reduction(self.x_lag.shape[1].value,
                                        self.pool.height, dilation,
                                        self.pool.stride[0], self.pool.padding)

            if new_dim != self.x.shape[1]:
                raise TypeError(
                    f"{self.name}: After transformation height of x must be equal than x_lag. "
                    f"Height for x_lag becomes {new_dim} whereas is {self.x.shape[1].value} for x."
                )

        if self.x.shape[2] > self.x_lag.shape[2]:
            raise TypeError(
                f"{self.name}: x must have width lower or equal than x_lag. "
                f"Width for x is {self.x.shape[2].value} whereas is {self.x_lag.shape[2].value} for x_lag."
            )

        elif self.x.shape[2] < self.x_lag.shape[2]:
            if any([
                    x is None for x in
                [self.pool.width, self.pool.stride, self.pool.padding]
            ]):
                raise TypeError(
                    "x_lag reduction needed. You must feed value for width, stride and padding. "
                )
            dilation = 0 if self.pool.dilation is None else self.pool.dilation[
                1]
            new_dim = get_dim_reduction(self.x_lag.shape[2].value,
                                        self.pool.width, dilation,
                                        self.pool.stride[1], self.pool.padding)

            if new_dim != self.x.shape[2]:
                raise TypeError(
                    f"{self.name}: After transformation width of x must be equal than x_lag. "
                    f"Width for x_lag becomes {new_dim} whereas is {self.x.shape[2].value} for x."
                )