"tests/vscode:/vscode.git/clone" did not exist on "60d915fbed5665534aa52bb98ef4444eac46715c"
Commit 59c35095 authored by Fan Yang's avatar Fan Yang Committed by A. Unique TensorFlower
Browse files

Add functionality to create fake data and use that in train_test to show how an e2e training works.

PiperOrigin-RevId: 381368435
parent 1d62fa0b
......@@ -143,3 +143,24 @@ def create_classification_example(
int64_list=tf.train.Int64List(value=labels))),
})).SerializeToString()
return serialized_example
def create_3d_image_test_example(image_height: int, image_width: int,
image_volume: int,
image_channel: int) -> tf.train.Example:
"""Creates 3D image and label."""
images = np.random.rand(image_height, image_width, image_volume,
image_channel)
images = images.astype(np.float32)
labels = np.random.randint(
low=2, size=(image_height, image_width, image_volume, image_channel))
labels = labels.astype(np.float32)
feature = {
IMAGE_KEY: (tf.train.Feature(
bytes_list=tf.train.BytesList(value=[images.tobytes()]))),
CLASSIFICATION_LABEL_KEY: (tf.train.Feature(
bytes_list=tf.train.BytesList(value=[labels.tobytes()])))
}
return tf.train.Example(features=tf.train.Features(feature=feature))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment