keras-VGG16 猫狗分类器

keras 原理:

keras系列︱图像多分类训练与利用bottleneck features进行微调(三)https://blog.csdn.net/sinat_26917383/article/details/72861152

基础篇:http://www.sohu.com/a/145534864_697750

Question1:

报错1:model.add(Convolution2D(32, 3, 3, input_shape=(3, 150, 150)))ValueError: Negative dimension size caused by subtracting 3 from 1 for 'conv2d_6/convolution' (op: 'Conv2D') with input shapes: [?,1,148,32], [3,3,32,32].

报错2:model.add(MaxPooling2D(pool_size=(2, 2)))

ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_11/MaxPool' (op: 'MaxPool') with input shapes: [?,1,148,32].

原因:

input_shape=(3,150, 150)是theano的写法,而tensorflow需要写出:(150,150,3);

需要修改Input_size。也就是”channels_last”和”channels_first”数据格式的问题。