Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

报错:模型预期有0层,但是预训练权重有9层 #13

Open
znygithub opened this issue Apr 6, 2024 · 1 comment
Open

报错:模型预期有0层,但是预训练权重有9层 #13

znygithub opened this issue Apr 6, 2024 · 1 comment

Comments

@znygithub
Copy link

运行命令:python inference.py --video 1424.avi --model efficientphys --show-wave发生了两个报错:

  1. 模型中有一个名为 'ep' 的层,这个层的 build() 方法被调用了,但是这个层并没有实现 build() 方法。这可能会导致一些问题,因为这个层会被标记为已经构建(built),尽管它实际上并没有被构建。
  2. 模型预期有0层,但是预训练权重有9层

记录一下报错记录:

PS D:\桌面\PhysBench\PhysBench> python inference.py --video 1424.avi --model efficientphys --show-wave
2024-04-06 15:10:53.108186: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation
orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2024-04-06 15:10:53.789180: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation
orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2024-04-06 15:10:55.480582: 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 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
D:\Anaconda\envs\physbench\lib\site-packages\keras\src\layers\layer.py:357: UserWarning: build() was called on layer 'ep', however the layer does not have a build() method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper build() method.
warnings.warn(
Traceback (most recent call last):
File "D:\桌面\PhysBench\PhysBench\inference.py", line 53, in
ep.load_weights('./weights/EfficientPhys_UBFC.h5')
File "D:\Anaconda\envs\physbench\lib\site-packages\keras\src\utils\traceback_utils.py", line 122, in error_handler
raise e.with_traceback(filtered_tb) from None
File "D:\Anaconda\envs\physbench\lib\site-packages\keras\src\legacy\saving\legacy_h5_format.py", line 357, in load_weights_from_hdf5_group
raise ValueError(
ValueError: Layer count mismatch when loading weights from file. Model expected 0 layers, found 9 saved layers.

@electroendjneer
Copy link

Try to install tensorflow==2.15.1. The problem is the keras version >=3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants