Skip to content

Error with keras.applications.EfficientNetB0() #21692

@t-kalinowski

Description

@t-kalinowski

To reproduce run:

python3 -c 'import keras; keras.applications.EfficientNetB0()'
python3 -c 'import keras;keras.applications.EfficientNetB0()'
2025-09-24 18:16:56.122355: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1758752218.079873 1275074 gpu_device.cc:2020] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 9613 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 2080 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5
I0000 00:00:1758752218.080927 1275074 gpu_device.cc:2020] Created device /job:localhost/replica:0/task:0/device:GPU:1 with 666 MB memory:  -> device: 1, name: NVIDIA GeForce RTX 2080 Ti, pci bus id: 0000:03:00.0, compute capability: 7.5
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/tomasz/.cache/R/reticulate/uv/cache/archive-v0/y3soa2jYCeG7RqToCIoJ5/lib/python3.11/site-packages/keras/src/applications/efficientnet.py", line 571, in EfficientNetB0
    return EfficientNet(
           ^^^^^^^^^^^^^
  File "/home/tomasz/.cache/R/reticulate/uv/cache/archive-v0/y3soa2jYCeG7RqToCIoJ5/lib/python3.11/site-packages/keras/src/applications/efficientnet.py", line 434, in EfficientNet
    model.load_weights(weights_path)
  File "/home/tomasz/.cache/R/reticulate/uv/cache/archive-v0/y3soa2jYCeG7RqToCIoJ5/lib/python3.11/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/tomasz/.cache/R/reticulate/uv/cache/archive-v0/y3soa2jYCeG7RqToCIoJ5/lib/python3.11/site-packages/keras/src/legacy/saving/legacy_h5_format.py", line 452, in _set_weights
    raise ValueError(
ValueError: Shape mismatch in layer #1 (named stem_conv)for weight stem_conv/kernel. Weight expects shape (3, 3, 1, 32). Received saved weight with shape (3, 3, 3, 32)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions