concept transfer in category machine learning

This is an excerpt from Manning's book Human-in-the-Loop Machine Learning.
You could also choose to look at multiple layers at once. This is one of the approaches used in transfer learning with pre-trained models: the model is “flattened” to create one single vector combining all the layers. We’ll cover these in more detail in a later chapter. You could use a flattened model for outlier detection, too, but you might want to normalize by the amount of neurons per layer. For example, in our model the 128 neurons in the hidden layer would become the main contributor to an outlier detection algorithm that also included the 2 neurons from the final layer. So, you might want to calculate the outlier ranking for the layers independently and then combine the two results.
def get_atlas_samples(self, model, unlabeled_data, validation_data, feature_method, number=100, limit=10000, number_per_iteration=10, epochs=10, select_per_epoch=100): """Uses transfer learning to predict uncertainty within the model Keyword arguments: model -- machine learning model to get predictions from to determine uncertainty unlabeled_data -- data that does not yet have a label validation_data -- data with a label that is not in the training set, to be used for transfer learning feature_method -- the method for extracting features from your data number -- number of items to sample number_per_iteration -- number of items to sample per iteration limit -- sample from only this many items for faster sampling (-1 = no limit) """ if(len(unlabeled_data) < number): raise Exception('More samples requested than the number of unlabeled items') atlas_samples = [] # all items sampled by atlas while(len(atlas_samples) < number): samples = self.get_deep_active_transfer_learning_uncertainty_samples(model, unlabeled_data, validation_data, feature_method, number_per_iteration, limit, epochs, select_per_epoch) for item in samples: atlas_samples.append(item) unlabeled_data.remove(item) item = copy.deepcopy(item) item[3] = "seen" # mark this item as already seen validation_data.append(item) # append so that it is in the next iteration return atlas_samples
Figure 9.14: An example of a contextual embedding. We have the task of predicting whether an item is “A” or “B”, and we think that our existing model that predicts “X”, “Y”, or “Z” will have useful information because of similarities between the two tasks. So, we can use the neurons from the “X”, “Y”, or “Z” model as features in our model predicting “A” or “B”. This is similar to the examples earlier in the book where we used the hidden layers as features for clustering and used transfer learning to adapt an existing model to a new task.
![]()
Because it takes a lot of time to manually create data for language generation, you can get a great deal of speed-up from machine learning. In fact, you probably use one example of this kind of technology regularly. If your phone or email client offers predictive next word or sentence completion functionality, then you are the human in human-in-the-loop sequence generation! Depending on the technology, it might be using transfer learning by starting with a general sentence-completion algorithm and gradually adapting the model to your text.