Hi everyone,
I have been battling with this for days now and at the moment, ChatGpt cant help me and will appreciate any help out there.
So, I am building a tensorflow input pipeline for u_net and my current challenge is executing a data augmentation function I defined. So, before the data augment () func, I applied two other functios which I will describe below. I will use Alphabets to show my steps and where I am stuck;
(A) I created a dataset; dataset = tf.data.Dataset.from_tensor_slices ((img_paths, mask_paths)).
(B) I have preprocess func () that takes the same arguments (img_paths, mask_paths) and returns img, maskâ; dataset = dataset.map(preprocess).
(C) using the output, I transformed the data further with another functn; dataset = dataset.map (img_resize). img_resize is defined to take img, mask images as arguments and return img, mask in a new size.
(D) Now, here is where my problem began; Note: augment () func is defined to take 4 arguments; (1) dataset, which is (img, mask) from resize () output, (2) seed, (3) si and (4) ir. All these arguments are created using tf.data.Dataset.from_tensor_slices (), e.g, tf.data.Dataset.from_tensor_slices (si), where si is a list of floating values.
After creating these arguments, I ran
[print(dataset.cardinality())
print(seed.cardinality())
print(si.cardinality())
print(ir.cardinality())], all returned the same result [tf.Tensor(24, shape=(), dtype=int64)], meaning there is no mismatch.
I also ran
[print(len(dataset))
print(len(seed))
print(len(si))
print(len(ir))] and got the same output; 24 from all. The augment () is designed to return img, mask as usual.
(E) At this point, I modified the dataset using zip () like this;
dataset_zip = tf.data.Dataset.zip ((dataset, seed, si, ir)) and tried to apply the augment () using map () as usual;
dataset = dataset_zip.map(augment) and here is the Error message most of the times; [OperatorNotAllowedInGraphError: in user code:
File "C:\\Users\\bildad\\AppData\\Local\\Temp\\ipykernel_5152\\381901545.py", line 44, in augment \*
seed1, seed2, seed3, seed4 = tf.random.experimental.stateless_split (seed, 4)
OperatorNotAllowedInGraphError: Iterating over a symbolic \`tf.Tensor\` is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.\].
(F) I tried applying the augment () using another format [dataset = dataset_zip.map(
lambda dataset, seed, si, ir: augment(dataset, seed, si, ir))], but got the same error message.
I canât figure out why the augment() function isnât working. Your help will be highly appreciated.
Thank you in advance.