MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / write_examples

Function write_examples

tensorflow/lite/testing/generate_examples_lib.py:170–195  ·  view source on GitHub ↗

Given a list `examples`, write a text format representation. The file format is csv like with a simple repeated pattern. We would ike to use proto here, but we can't yet due to interfacing with the Android team using this format. Args: fp: File-like object to write to. examples: Ex

(fp, examples)

Source from the content-addressed store, hash-verified

168
169
170def write_examples(fp, examples):
171 """Given a list `examples`, write a text format representation.
172
173 The file format is csv like with a simple repeated pattern. We would ike
174 to use proto here, but we can't yet due to interfacing with the Android
175 team using this format.
176
177 Args:
178 fp: File-like object to write to.
179 examples: Example dictionary consiting of keys "inputs" and "outputs"
180 """
181
182 def write_tensor(fp, x):
183 """Write tensor in file format supported by TFLITE example."""
184 fp.write("dtype,%s\n" % x.dtype)
185 fp.write("shape," + ",".join(map(str, x.shape)) + "\n")
186 fp.write("values," + format_result(x) + "\n")
187
188 fp.write("test_cases,%d\n" % len(examples))
189 for example in examples:
190 fp.write("inputs,%d\n" % len(example["inputs"]))
191 for i in example["inputs"]:
192 write_tensor(fp, i)
193 fp.write("outputs,%d\n" % len(example["outputs"]))
194 for i in example["outputs"]:
195 write_tensor(fp, i)
196
197
198def write_test_cases(fp, model_name, examples):

Callers 1

build_exampleFunction · 0.85

Calls 2

write_tensorFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected