Input to reshape is a tensor with 3763200 values, but the requested shape requires a multiple of 20384
Hi, i used Swin as feature Extractor like :class SwinTransformer(tf.keras.Model):definit(self, model_name=“microsoft/swin-tiny-patch4-window7-224”):super(SwinTransformer, self).init()self.transformer = TFSwinModel.from_pretrained(model_name,use_auth_token=“REDACTED_TOKEN”)self.global_avg_pooling = tf.keras.layers.GlobalAveragePooling1D()def call(self, inputs):
    x = self.transformer(inputs)
    x = x.last_hidden_state
    x = self.global_avg_pooling(x)
    return xand the input size is (batch_size, 3,224,224); train_dataset = train_dataset.shuffle(1000).batch(25,drop_remainder=True)Here is the problem:when training the model, it only work in specific batch size like 1,2,3,9,30. Other batch size would cause problem like below, it’s like there are some problem in the swin window, but it’s weird ? do anyone know what is going on here and how to fix this, appreciate that a lot~ :File “/home/yilei/MT/video_sync/models/featureExtractor.py”, line 126, in callx = self.transformer(inputs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 65, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/engine/training.py”, line 557, incallreturn super().call(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 65, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/engine/base_layer.py”, line 1097, incalloutputs = call_fn(inputs, *args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 96, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/modeling_tf_utils.py”, line 1198, in run_call_with_unpacked_inputs“”"File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 1213, in callswin_outputs = self.swin(File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 65, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/engine/base_layer.py”, line 1097, incalloutputs = call_fn(inputs, *args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 96, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/modeling_tf_utils.py”, line 1198, in run_call_with_unpacked_inputs“”"File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 1137, in callencoder_outputs = self.encoder(File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 65, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/engine/base_layer.py”, line 1097, incalloutputs = call_fn(inputs, *args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 96, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 910, in callfor i, layer_module in enumerate(self.layers):File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 913, in calllayer_outputs = layer_module(File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 65, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/engine/base_layer.py”, line 1097, incalloutputs = call_fn(inputs, *args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 96, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 842, in callfor i, layer_module in enumerate(self.blocks):File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 845, in calllayer_outputs = layer_module(File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 65, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/engine/base_layer.py”, line 1097, incalloutputs = call_fn(inputs, *args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 96, in error_handlerreturn fn(*args, **kwargs)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 769, in callshifted_windows = window_reverse(attention_windows, window_size, height_pad, width_pad)File “/home/yilei/anaconda3/envs/MT_tf/lib/python3.7/site-packages/transformers/models/swin/modeling_tf_swin.py”, line 243, in window_reversewindows = tf.reshape(Node: ‘model/swin_transformer/tf_swin_model/swin/encoder/layers.1/blocks.0/Reshape_33’Input to reshape is a tensor with 3763200 values, but the requested shape requires a multiple of 20384[[{{node model/swin_transformer/tf_swin_model/swin/encoder/layers.1/blocks.0/Reshape_33}}]] [Op:__inference_train_function_171382]ERROR conda.cli.main_run:execute(49):conda run python /home/yilei/MT/video_sync/exp_loss/train_disR.pyfailed. (See above for error)