3
我Keras' image_dim_ordering
属性设置为‘TF’,所以我定义我的模型,因为这:加载重物时keras设置为TF格式
model = Sequential()
model.add(ZeroPadding2D((1, 1), input_shape=(224, 224, 3)))
model.add(Convolution2D(64, 3, 3, activation='relu'))
但是当我打电话load_weights
方法,
Exception: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3)
我如何可以加载这些权重,并自动转他们解决Tensorflow的格式:崩溃,因为我的模型是用“日”的格式保存的?
现在看来并非如此。 Theano和TensorFlow都具有相同的重量形状。当从“Th”转换为“TF”(反之亦然)时,我们必须翻转维度1和2(即“输入深度”和“深度”)。你知道这是为什么吗?如果你想看看从Th到TF(或反向)的kernel_conversion函数,看看[这里](https://github.com/fchollet/keras/blob/master/keras/utils/conv_utils.py#L67-L87) 。 –