green_ai_bench.generate_data

[docs] module green_ai_bench.generate_data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np


def generate_data(
    name,
    low=2,
    high=20,
    num_of_images=1,
    image_height=224,
    image_width=224,
    channels=3,
    channel_first=False,
):
    """Generate random input data for the model."""
    # Generate random dataset
    if channel_first:
        dataset = np.random.randint(
            low, high, (num_of_images, channels, image_height, image_width)
        ).astype(np.float32)
    else:
        dataset = np.random.randint(
            low, high, (num_of_images, image_height, image_width, channels)
        ).astype(np.float32)
    dataset = np.ascontiguousarray(dataset)

    # Create the input_data dictionary
    input_data = {name: dataset}
    return input_data, dataset