Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrain Tensorflow final layer but still use previous Imagenet classes

My objective is to "add" more classes to the existing 1000 Imagenet classes that came with Tensorflow Inception. Now I could just re-run the whole thing by training from scratch using bazel-bin/inception/imagenet_train but that would take a long time especially each time I want to add a new class.

Is it possible to use bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir ~/flower_photos but then add to the existing label output file?

Sorry I am a newbie.

like image 360
HP. Avatar asked May 05 '17 07:05

HP.


People also ask

How do you retrain Inception's final layer for new categories?

In theory all you'll need to do is point it at a set of sub-folders, each named after one of your categories and containing only images from that category. If you do that and pass the root folder of the subdirectories as the argument to --image_dir , the script should train just like it did for the flowers.


1 Answers

You could brazenly add a second last layer, that also refers to the second to last layer... Of course, that's kind of a hack and not practical if you wanna do the procedure multiple times...

Alternatively, you replace the output layer and before you do that, you save the previous weights for that layer manually and, then reload the whole net with something like this optimistic restore and add the old weights, that you also have to reload separately, to your now bigger weight-matrix manually.

enter image description here

like image 156
Xethoras Avatar answered Nov 16 '22 00:11

Xethoras