【问题标题】:ValueError: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3) when using kerasValueError:使用 keras 时,层权重形状 (3, 3, 3, 64) 与提供的权重形状 (64, 3, 3, 3) 不兼容
【发布时间】:2019-11-20 17:37:20
【问题描述】:

我遇到了ValueError: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3)中描述的相同错误

当我使用时:

K.set_image_dim_ordering('tf')

我收到了这个错误

Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering'

当我使用其他解决方案时:

from keras.utils.conv_utils import convert_kernel
reshaped_weights = convert_kernel(weights)
model.layers[k].set_weights(reshaped_weights)

我收到了这个错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 11, in load_model_weights
  File "/home/khawkha/.virtualenvs/DeepMS/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 78, in convert_kernel
    raise ValueError('Invalid kernel shape:', kernel.shape)
ValueError: ('Invalid kernel shape:', (0,))

keras 版本:'2.3.1' 张量流版本:1.15.0

【问题讨论】:

    标签: python-3.x keras conv-neural-network vgg-net


    【解决方案1】:

    我认为第一个valueerror可能是keras版本不同造成的。模型权重文件的keras和你调用的keras不一样。

    【讨论】:

      猜你喜欢
      • 2019-02-01
      • 2021-07-07
      • 1970-01-01
      • 2021-07-27
      • 1970-01-01
      • 2022-06-15
      • 2020-03-20
      • 1970-01-01
      相关资源
      最近更新 更多