I have the following code which uses TensorFlow. After I called map on my dataset list, it says
AttributeError: 'Tensor' object has no attribute 'shape'
when I try to map elements.
Output:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[16], line 6
3 BATCH_SIZE = 1
5 train_dataset = tf.data.Dataset.list_files('training/Minimalist_Interior/*.jpg')
----> 6 train_dataset = train_dataset.map(load_image_train, num_parallel_calls=tf.data.AUTOTUNE)
7 train_dataset = train_dataset.shuffle(BUFFER_SIZE)
8 train_dataset = train_dataset.batch(BATCH_SIZE)
.
.
.
File ~AppDataLocalTemp__autograph_generated_fileb73k_ejd.py:11, in outer_factory.<locals>.inner_factory.<locals>.tf__load_image_train(image_file)
9 retval_ = ag__.UndefinedReturnValue()
10 input_image = ag__.converted_call(ag__.ld(load), (ag__.ld(image_file),), None, fscope)
---> 11 real_image = ag__.converted_call(ag__.ld(load), (ag__.converted_call(ag__.ld(image_file).replace, ('input', 'output'), None, fscope),), None, fscope)
12 input_image, real_image = ag__.converted_call(ag__.ld(random_jitter), (ag__.ld(input_image), ag__.ld(real_image)), None, fscope)
13 input_image, real_image = ag__.converted_call(ag__.ld(normalize), (ag__.ld(input_image), ag__.ld(real_image)), None, fscope)
File ~AppDataLocalProgramsPythonPython312Libsite-packagestensorflowpythonframeworktensor.py:260, in Tensor.__getattr__(self, name)
252 if name in {"T", "astype", "ravel", "transpose", "reshape", "clip", "size",
253 "tolist", "data"}:
254 # TODO(wangpeng): Export the enable_numpy_behavior knob
255 raise AttributeError(
256 f"{type(self).__name__} object has no attribute '{name}'. " + """
257 If you are looking for numpy-related methods, please run the following:
258 tf.experimental.numpy.experimental_enable_numpy_behavior()
259 """)
--> 260 self.__getattribute__(name)
AttributeError: in user code:
File "C:UsersjenesAppDataLocalTempipykernel_202484005255074.py", line 12, in load_image_train *
real_image = load(image_file.replace('input', 'output'))
AttributeError: 'SymbolicTensor' object has no attribute 'replace'
Could anyone please tell me what I am missing?