retrain a saved model in scikit-learn - python

I am a newbie in machine learning and currently working with scikit-learn python library.I want to know if there is a way to add more training data to a already trained neural network.For example,I am loading a trained neural net instance from a pickle file.Now If I get a wrong prediction,I want to add it to my training data.is that possible?

Related

How to train a trained model with new examples in scikit-learn?

I'm working on a machine learning classification task in which I have trained many models with different algorithms in scikit-learn and Random Forest Classifier performed the best. Now I want to train the model further with new examples but if I train the same model by calling the fit method on new examples then it will start training the model from beginning by erasing the old parameters.
So, how can I train the trained model by training it with new examples in scikit-learn?
I got some idea by reading online to pickle and unpickle the model but how would it help I don't know.
You should use incremental learning and estimators implementing the partial_fit API.
RandomForrestClassifier has a flag warm_start. Note that this will not give the same results as if you train on both sets at once.
Append the new data to your existing dataset, and train over the whole thing. Might want to reserve some of the new data for your testset.

Retrain Tensorflow model

I have a tensorflow model which I trained using object detection SSD mobile net .
The training is finished now and I exported the model inference for testing .My inquiry is if I want to retrain the model later with new dataset of images, what should i do now at the stage to make the weights permeant in the model so that I can retrain it from that point on .I know there is a freeze script ,do I have to use that ?
Thanks
Ayad
You cannot retrain it from that point on. Every time you retrain it should be for all objects that you are interested in.

How to train a convolution neural network with my own dataset for image clasification and save it as .pb.Everything in tensorflow and python

I want to learn how to train a convolution neural network in tensorflow.May you write a link with some code.For example a github project.After I train the convolution neural network with my own dataset ,how to save it as .pb or .pbtxt.May you discribe the procedure to do that?
Well not sure if you want code you can understand or just a model. If you want just the model check out this retraining code of tensorflow. For full understanding, this link might be useful. The pb file you're referring to is also called a saved model, see this link.

Is it possible to add another dataset on my trained model in tensorflow?

I already trained a custom person detector which doesn't work well on detecting perons on aerial footage which is because my dataset lacks on aerial images of a person. Can I continue the training using the latest checkpoint and add another dataset (different tfrecord file) for my model or do I have to restart the training using the updated dataset?
I retrained the Inception model to detect persons only since there no other way to remove the other 89 objects from the pretrained model.
You can definitely start from a checkpoint using another dataset. However, it might not be a good idea to train only on a subset of your data due to the tendency of neural nets to forget what they'e already learned (a problem known as catastrophic forgetting). It's probably a better idea to create a new dataset that includes both your old and new data, and either pick up from the checkpoint using those data (similar to how you fine-tuned the Inception model), or start the training process over.

Image Retrain Inception only check the own specific category not tensor dataset

I have retrained the inception model from my data set of traffic sign.Its working fine but when I am trying to check other image e.g panda it's resulting with the name of traffic sign with some probabilities.I don't understand why its doing it.I need both tensor-flow data-set and my own category too.
My steps:
I have installed the python 3.5.2 in windows 7
I installed tensor-flow with
pip --install tensorflow
I download these two files retrain.py to train my data and label_image.py to check image.
Files downloaded from:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/image_retraining
You have misunderstood the fundamentals of transfer learning wrt this image retraining program.
In the image retraining program you are referencing, you are taking the inception CNN model that is already pretraining on the imageNET dataset. You are then retraining the final classification layers on your NEW classes and data.
The transfer learning occurs because you are retaining all the learnt feature extraction filters etc. in the early layers and you are just reclassifying the activations of those layers to new classes based on your new dataset. This means you are replacing the classification part with a new one. AFAIK there is no way to simply add classes to a CNN model via transfer learning because you have already trained a softmax layer (for example) with the classification distribution for each class.
To achieve what you are suggesting will require you to retrain the final layers of inception with the original dataset PLUS your additional data. This will take a long time due to the size of imageNET.
I would re-evaluate whether you actually need to be able to utilise all these classes in your application or whether it is sufficient to just have your traffic signs etc.
You can learn more about the program at the tensorflow tutorial here.

Categories