Created
March 8, 2024 20:02
-
-
Save tomigee/6c5b39629305463d9799b8ae5e5548b9 to your computer and use it in GitHub Desktop.
[Traceback for Bug Report] TFBertModel: InvalidArgumentError.__init__() missing 2 required positional arguments: 'op' and 'message'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InvalidArgumentError Traceback (most recent call last) | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/transformers/modeling_tf_pytorch_utils.py:348, in load_pytorch_state_dict_in_tf2_model(tf_model, pt_state_dict, tf_inputs, allow_missing_keys, output_loading_info, _prefix, tf_to_pt_weight_rename, ignore_mismatched_sizes) | |
347 try: | |
--> 348 array = apply_transpose(transpose, array, symbolic_weight.shape) | |
349 except tf.errors.InvalidArgumentError as e: | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/transformers/modeling_tf_pytorch_utils.py:143, in apply_transpose(transpose, weight, match_shape, pt_to_tf) | |
142 try: | |
--> 143 weight = reshape(weight, match_shape) | |
144 except AssertionError as e: | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/transformers/utils/generic.py:620, in reshape(array, newshape) | |
618 import tensorflow as tf | |
--> 620 return tf.reshape(array, newshape) | |
621 elif is_jax_tensor(array): | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/tensorflow/python/ops/weak_tensor_ops.py:88, in weak_tensor_unary_op_wrapper.<locals>.wrapper(*args, **kwargs) | |
87 if not ops.is_auto_dtype_conversion_enabled(): | |
---> 88 return op(*args, **kwargs) | |
89 bound_arguments = signature.bind(*args, **kwargs) | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback.<locals>.error_handler(*args, **kwargs) | |
152 filtered_tb = _process_traceback_frames(e.__traceback__) | |
--> 153 raise e.with_traceback(filtered_tb) from None | |
154 finally: | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/tensorflow/python/eager/execute.py:53, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name) | |
52 ctx.ensure_initialized() | |
---> 53 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, | |
54 inputs, attrs, num_outputs) | |
55 except core._NotOkStatusException as e: | |
InvalidArgumentError: {{function_node __wrapped__Reshape_device_/job:localhost/replica:0/task:0/device:GPU:0}} Input to reshape is a tensor with 393216 values, but the requested shape has 1572864 [Op:Reshape] | |
During handling of the above exception, another exception occurred: | |
TypeError Traceback (most recent call last) | |
Cell In[2], line 2 | |
1 configuration = BertConfig(max_position_embeddings=2048) | |
----> 2 bert = TFBertModel.from_pretrained("bert-base-uncased", config=configuration) | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/transformers/modeling_tf_utils.py:2903, in TFPreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs) | |
2897 from .modeling_tf_pytorch_utils import load_pytorch_state_dict_in_tf2_model | |
2899 with safe_open(resolved_archive_file, framework="tf") as safetensors_archive: | |
2900 # Load from a PyTorch checkpoint | |
2901 # We load in TF format here because PT weights often need to be transposed, and this is much | |
2902 # faster on GPU. Loading as numpy and transposing on CPU adds several seconds to load times. | |
-> 2903 return load_pytorch_state_dict_in_tf2_model( | |
2904 model, | |
2905 safetensors_archive, | |
2906 tf_inputs=False, # No need to build the model again | |
2907 allow_missing_keys=True, | |
2908 output_loading_info=output_loading_info, | |
2909 _prefix=load_weight_prefix, | |
2910 ignore_mismatched_sizes=ignore_mismatched_sizes, | |
2911 tf_to_pt_weight_rename=tf_to_pt_weight_rename, | |
2912 ) | |
2914 # 'by_name' allow us to do transfer learning by skipping/adding layers | |
2915 # see https://github.com/tensorflow/tensorflow/blob/00fad90125b18b80fe054de1055770cfb8fe4ba3/tensorflow/python/keras/engine/network.py#L1339-L1357 | |
2916 try: | |
File ~/miniconda3/envs/WeThePeople/lib/python3.10/site-packages/transformers/modeling_tf_pytorch_utils.py:355, in load_pytorch_state_dict_in_tf2_model(tf_model, pt_state_dict, tf_inputs, allow_missing_keys, output_loading_info, _prefix, tf_to_pt_weight_rename, ignore_mismatched_sizes) | |
351 error_msg = str(e) | |
352 error_msg += ( | |
353 "\n\tYou may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method." | |
354 ) | |
--> 355 raise tf.errors.InvalidArgumentError(error_msg) | |
356 else: | |
357 mismatched_keys.append((name, array.shape, symbolic_weight.shape)) | |
TypeError: InvalidArgumentError.__init__() missing 2 required positional arguments: 'op' and 'message' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment