Using VGG16 as a sequential model in tf.keras and splitting data

75 views
Skip to first unread message

Osuman AAA

unread,
Apr 7, 2021, 11:25:43 PM4/7/21
to Keras-users


I recently started again working on building and training models, so I naturally went for tf.keras (tf 2.4) hoping it is better. So far, I've had my share of frustration.

I remember loading VGG16 and going through its layers to add them to a sequential model used to be simpler. Now when I do, for some reason, the input layer is not copied (and I found answers saying it's not needed as it has no parameters). I am just concerned about whether that will be an issue if I leave it as it is. I tried adding input layers after creating the sequential model, creating it with a dense layer and other methods, but I keep getting errors. Is it fine to leave it like that or is there a way (and a need) to add the input ?

Also, I was happy to see that Keras has added a parameter in the datagenerator method to split data into a validation set. That would save me time in making separate folders for the image datasets. However, I couldn't find a way to split into a test set. Is there a method to do that or should I just go with the old fashioned way ?

Thanks a lot in advance

Lance Norskog

unread,
Apr 8, 2021, 3:14:05 PM4/8/21
to Osuman AAA, Keras-users
Model is a subclass of Layer. You can load a VGG16 model using the utilities and then use that pre-packaged model as a layer in another model.

This is an example of this technique using EfficientNetB0:

Search for: "Transfer learning from pre-trained weights" 
This part loads the weights and adds a predictor "top" (output layer sequence).



--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/49fb7c99-990b-4c33-a388-5fd7646d9234n%40googlegroups.com.


--
Lance Norskog
lance....@gmail.com
Redwood City, CA
Reply all
Reply to author
Forward
0 new messages