transfer-learning

Cannot predict the label for a single image with VGG19 in Keras

醉酒当歌 提交于 2019-11-29 12:27:35
I'm using transfer learning method to use per-trained VGG19 model in Keras according to [this tutorial]( https://towardsdatascience.com/keras-transfer-learning-for-beginners-6c9b8b7143e ). It shows how to train the model but NOT how to prepare test images for the predictions. In the comments section it says: Get an image, preprocess the image using the same preprocess_image function, and call model.predict(image) . This will give you the prediction of the model on that image. Using argmax(prediction) , you can find the class to which the image belongs. I can not find a function named

Strange behaviour of the loss function in keras model, with pretrained convolutional base

落爺英雄遲暮 提交于 2019-11-27 16:11:30
I'm trying to create a model in Keras to make numerical predictions from the pictures. My model has densenet121 convolutional base, with couple of additional layers on top. All layers except for the two last ones are set to layer.trainable = False . My loss is mean squared error, since it's a regression task. During training I get loss: ~3 , while evaluation on the very same batch of the data gives loss: ~30 : model.fit(x=dat[0],y=dat[1],batch_size=32) Epoch 1/1 32/32 [==============================] - 0s 11ms/step - loss: 2.5571 model.evaluate(x=dat[0],y=dat[1]) 32/32 [=======================