0

I was using the colab notebook in the link below and it was working fine.

https://www.tensorflow.org/tutorials/video/video_classification

Now I am trying to use it again and I am getting the error below when I start fitting the model.

----> 3 history = model.fit(x = train_ds,
      4                     epochs = 5,
      5                     validation_data = val_ds, )

4 frames
/usr/local/lib/python3.9/dist-packages/einops/einops.py in tf__reduce(tensor, pattern, reduction, **axes_lengths)
     61                 try:
     62                     hashable_axes_lengths = ag__.converted_call(ag__.ld(tuple), (ag__.converted_call(ag__.ld(sorted), (ag__.converted_call(ag__.ld(axes_lengths).items, (), None, fscope),), None, fscope),), None, fscope)
---> 63                     recipe = ag__.converted_call(ag__.ld(_prepare_transformation_recipe), (ag__.ld(pattern), ag__.ld(reduction)), dict(axes_lengths=ag__.ld(hashable_axes_lengths)), fscope)
     64                     try:
     65                         do_return = True

TypeError: in user code:

    File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1284, in train_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1268, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1249, in run_step  **
        outputs = model.train_step(data)
    File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1050, in train_step
        y_pred = self(x, training=True)
    File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 70, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/tmp/__autograph_generated_file01sh7f7r.py", line 22, in tf__call
        videos = ag__.converted_call(ag__.ld(einops).rearrange, (ag__.ld(images), '(b t) h w c -> b t h w c'), dict(t=ag__.ld(old_shape)['t']), fscope)
    File "/tmp/__autograph_generated_filefu2t6yqk.py", line 95, in tf__rearrange
        retval_ = ag__.converted_call(ag__.ld(reduce), (ag__.converted_call(ag__.ld(cast), (ag__.ld(Tensor), ag__.ld(tensor)), None, fscope), ag__.ld(pattern)), dict(reduction='rearrange', **ag__.ld(axes_lengths)), fscope)
    File "/tmp/__autograph_generated_filerptbnnwp.py", line 63, in tf__reduce
        recipe = ag__.converted_call(ag__.ld(_prepare_transformation_recipe), (ag__.ld(pattern), ag__.ld(reduction)), dict(axes_lengths=ag__.ld(hashable_axes_lengths)), fscope)

    TypeError: Exception encountered when calling layer 'resize_video_2' (type ResizeVideo).
    
    in user code:
    
        File "<ipython-input-4-99a2af494be2>", line 23, in call  *
            videos = einops.rearrange(
        File "/usr/local/lib/python3.9/dist-packages/einops/einops.py", line 483, in rearrange  *
            return reduce(cast(Tensor, tensor), pattern, reduction='rearrange', **axes_lengths)
        File "/usr/local/lib/python3.9/dist-packages/einops/einops.py", line 411, in reduce  *
            recipe = _prepare_transformation_recipe(pattern, reduction, axes_lengths=hashable_axes_lengths)
    
        TypeError: Tensor is unhashable. Instead, use tensor.ref() as the key.
    
    
    Call arguments received by layer 'resize_video_2' (type ResizeVideo):
      • video=tf.Tensor(shape=(None, None, None, None, 16), dtype=float32)

I tried to disabled eager execution (code below) which was suggested for a similar error but it didn't work. I tried to reinstall and import the einops which also failed.

import tensorflow.compat.v1.keras.backend as K
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
Hammond
  • 11
  • 2

1 Answers1

0

I found out TensorFlow released a new version (2.12.0). It seems like einops is not compatible with the new version.

I downgraded TensorFlow to 2.11.0 and now it is working again.

!pip install tensorflow==2.11.0

Hammond
  • 11
  • 2