Generate numpy data as the inputs of model Parameters ---------- input_shapes: Union[Tuple, List[Tuple]] shapes for inputs dtype: str the data type of inputs Results ------- out: List[np.ndarray] numpy input data
(
input_shapes: tuple | list[tuple], dtype: str = "float32"
)
| 39 | |
| 40 | |
| 41 | def generate_np_inputs( |
| 42 | input_shapes: tuple | list[tuple], dtype: str = "float32" |
| 43 | ) -> np.ndarray | list[np.ndarray]: |
| 44 | """Generate numpy data as the inputs of model |
| 45 | |
| 46 | Parameters |
| 47 | ---------- |
| 48 | input_shapes: Union[Tuple, List[Tuple]] |
| 49 | shapes for inputs |
| 50 | dtype: str |
| 51 | the data type of inputs |
| 52 | |
| 53 | Results |
| 54 | ------- |
| 55 | out: List[np.ndarray] |
| 56 | numpy input data |
| 57 | """ |
| 58 | if not isinstance(input_shapes[0], list | tuple): |
| 59 | return [np.random.uniform(size=input_shapes).astype(dtype)] |
| 60 | out = [] |
| 61 | for input_shape in input_shapes: |
| 62 | out.append(np.random.uniform(size=input_shape).astype(dtype)) |
| 63 | return out |
| 64 | |
| 65 | |
| 66 | def np2jnp(inputs_np: np.ndarray | list[np.ndarray]): |
no test coverage detected
searching dependent graphs…