张量'object没有'lower'属性

2024-05-16 18:30:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用14个新类微调MobileNet。当我通过以下方式添加新层时:

x=mobile.layers[-6].output
x=Flatten(x)
predictions = Dense(14, activation='softmax')(x)
model = Model(inputs=mobile.input, outputs=predictions)

我知道错误:

'Tensor' object has no attribute 'lower'

同时使用:

model.compile(Adam(lr=.0001), loss='categorical_crossentropy', metrics=['accuracy'])
model.fit_generator(train_batches, steps_per_epoch=18,
                validation_data=valid_batches, validation_steps=3, epochs=60, verbose=2)

我知道错误:

Error when checking target: expected dense_1 to have 4 dimensions, but got array with shape (10, 14)

lower是什么意思?我看到了其他微调脚本,除了模型的名称(在本例中是X)之外,没有其他参数。


Tags: outputmodellayers错误方式batchesmobilesteps