14parser = argparse.ArgumentParser()
15parser.add_argument(
'--model', type=str, required=
True)
16parser.add_argument(
'--num_data', type=int, required=
True)
17parser.add_argument(
'--output', type=str, required=
True)
18args = parser.parse_args()
22num_data = args.num_data
24output_path = args.output
27interpreter = tf.lite.Interpreter(model)
28input_details = interpreter.get_input_details()
31h5_file = h5.File(output_path,
'w')
32group = h5_file.create_group(
"value")
33group.attrs[
'desc'] =
"Input data for " + model
36for i
in range(num_data):
37 sample = group.create_group(
str(i))
38 sample.attrs[
'desc'] =
"Input data " +
str(i)
40 for j
in range(len(input_details)):
41 input_detail = input_details[j]
42 print(input_detail[
"dtype"])
43 if input_detail[
"dtype"] == np.bool_:
45 input_data = np.array(np.random.random_integers(0, 1, input_detail[
"shape"]),
46 input_detail[
"dtype"])
47 elif input_detail[
"dtype"] == np.float32:
49 input_data = np.array(10 * np.random.random_sample(input_detail[
"shape"]) - 5,
50 input_detail[
"dtype"])
51 sample.create_dataset(
str(j), data=input_data)