I have one tensor slice with all image and one tensor with its masking image.
how do i combine/join/add them and make it a single tensor dataset tf.data.dataset
# turning them into tensor data
val_img_data = tf.data.Dataset.from_tensor_slices(np.array(all_val_img))
val_mask_data = tf.data.Dataset.from_tensor_slices(np.array(all_val_mask))
then i mapped a function to paths to make them image
val_img_tensor = val_img_data.map(get_image)
val_mask_tensor = val_mask_data.map(get_image)
So now i have two tensors one image and other mask. how do i join them and make it a tensor data combined?
I tried zipping them: it didn't work.
val_data = tf.data.Dataset.from_tensor_slices(zip(val_img_tensor, val_mask_tensor))
Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/structure.py in normalize_element(element, element_signature)
101 if spec is None:
--> 102 spec = type_spec_from_value(t, use_fallback=False)
103 except TypeError:
11 frames
TypeError: Could not build a `TypeSpec` for <zip object at 0x7f08f3862050> with type zip
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
100 dtype = dtypes.as_dtype(dtype).as_datatype_enum
101 ctx.ensure_initialized()
--> 102 return ops.EagerTensor(value, ctx.device_name, dtype)
103
104
ValueError: Attempt to convert a value (<zip object at 0x7f08f3862050>) with an unsupported type (<class 'zip'>) to a Tensor.