Generates a InputSpec based on the description of input np.ndarray. Args: tensor(Tensor): the source numpy ndarray to generate a InputSpec instance Returns: A InputSpec instance generated from Tensor. Examples: .. code-block:: p
(
cls, ndarray: npt.NDArray[Any], name: str | None = None
)
| 318 | |
| 319 | @classmethod |
| 320 | def from_numpy( |
| 321 | cls, ndarray: npt.NDArray[Any], name: str | None = None |
| 322 | ) -> Self: |
| 323 | """ |
| 324 | Generates a InputSpec based on the description of input np.ndarray. |
| 325 | |
| 326 | Args: |
| 327 | tensor(Tensor): the source numpy ndarray to generate a InputSpec instance |
| 328 | |
| 329 | Returns: |
| 330 | A InputSpec instance generated from Tensor. |
| 331 | |
| 332 | Examples: |
| 333 | .. code-block:: pycon |
| 334 | |
| 335 | >>> import numpy as np |
| 336 | >>> from paddle.static import InputSpec |
| 337 | |
| 338 | >>> x = np.ones([2, 2], np.float32) |
| 339 | >>> x_spec = InputSpec.from_numpy(x, name='x') |
| 340 | >>> print(x_spec) |
| 341 | InputSpec(shape=(2, 2), dtype=paddle.float32, name=x, stop_gradient=False) |
| 342 | |
| 343 | """ |
| 344 | return cls(ndarray.shape, ndarray.dtype, name) |
| 345 | |
| 346 | def batch(self, batch_size: int | Size1) -> Self: |
| 347 | """ |
no outgoing calls