我想使用第三层的输出的VGG16网络。错误如下:
UserWarning: Model inputs must come from `keras.layers.Input` (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to your model was not an Input tensor, it was generated by layer input_1.
Note that in
我正在运行一个使用keras的预训练模型的分类和预测神经网络算法。现在我知道keras的输入形状是(224,224,3),但是我的输入具有这个形状(180, 200, 20),并且我得到了以下错误:
ValueError: Dimension 0 in both shapes must be equal, but are 3 and 64. Shapes are [3,3,20,64] and [64,3,3,3]. for 'Assign_32' (op: 'Assign') with input shapes: [3,3,20,64], [64,3,3,3]
PS: Keras为2.4.3
下面的函数构建了VGG16神经网络,没有完全连接的层,因为我只想得到特征映射。
from keras.models import Model
from keras.layers import Conv2D, MaxPooling2D, Input
import keras.backend as K
import tensorflow as tf
def VGG16(input_tensor=None):
input_shape = (None, None, 3)
if input_tensor == None:
input_tensor