# The Use of Transfer Learning for Activity Recognition in Instances of Heterogeneous Sensing
## 3 Transfer Learning Framework for Recognising Activities of Daily Living across Sensing Technology
### Teacher/Learner Phase
Where \(X\): unlabelled dataset, \(D_{S[:]}\): associated trained model(s), \(D^{\prime}_{S}\): complementary AR model different than \(D_{Sk}\), \(output\): n-dimensional tensor consisting of a tandem of features and predicted labels for \(X\), and \(D_{S}\): most informative learner model. ```
1:\(D_{Sk(unseenActRate)}=\) Error ratio for the AR model in index \(k\) given by (\(\sum_{k=1}^{l}\frac{D^{\prime}_{S}}{D_{Sk}}\)). \(Q=\) Configurable scalar set \(a\)-priori. 2:\(flag=\) Boolean variable to determine whether a condition has been satisfied. 3:\(boolean=False\). 4:\(threshold=Q\). 5:function\(getValidationUponRuleSchema(unseenActRate)\)
6:if The AR model \(D_{Sk}\) satisfies the configuration requirements defined in \(Q\) then
7: The model is considered as informative, hence \(flag=True\). 8:ends if
9:return \(flag\)
10:endstunction
```  
**Algorithm 2** Validation of the AR model determined by accuracy reached. The remaining of this Section presents the main dependencies contributing to structure Algorithm 1, namely, (i) _getValidationUponRuleSchema_, (ii) _setTrainingModel_, (iii) _setReferencedModel_, and (iv) _buildModel_. ```
1:Input:\(X=\) A pool of unlabelled instances. \(D_{Sk}=\) A specific trained AR model with index \(k\). OUTPUT:\(output[error]\) = Ratio of misclassified labels. 2:1: Library deep neural network as DNN. \(output[\cdot]=nil\). 3:function\(setTrainingModel(D_{Sk},X)\)
4: Build a classification model utilising the DNN library where the inputs are \(D_{Sk},X\). 5: Retrieve an n-dimensional tensor \(output\) from the DNN classification model. 6: Assign \(output\) the error lost corresponding to the misclassified instances \([error]\). 7: return \(output[error]\)
8:ends function
```  
**Algorithm 2** presents function _FD.getValidation-UponRuleSchema(\(\cdot\))_ consists of a conditional statement in which \(D_{Sk(unseenActRate)}\) is compared against a threshold \(Q\) as a metric to accept or reject given \(unseenActRate\). Note that the algorithm introduces as a threshold a unique rule which accepts any rational number settled _a-priori_ (Line 2), however, TL-FmRADLs can be extended to accommodate a more complex decision making criteria. Examples of how to diversify the making criteria rules could be regulated to guarantee the acceptance of at least one AR model as teacher given a \(D_{S[\cdot]}\), by opting for the top AR model regardless of its performance. Other alternatives could rely on modelling an acquisition function to acquire ground truth data over the calculation of probabilistic uncertainties [37]. _(ii) setTrainingModel._  
Algorithm 3 shows function _FD.setTrainingModel(\(\cdot\))_, which process consists on exploring the classification error lost of a determined AR model \(D_{Sk}\) given a pool of unlabelled instances \(X\). As TensorFlow [38] is an end-to-end open-source platform for machine-learning-enabled and a flexible ecosystem of tools and libraries to build and deploy machine-learning models easily, this algorithm makes use of the DNN libraries taken from TensorFlow (Line 1). It then performs a classification procedure utilising TensorFlow (Line 4), retrieves the statistical results (Line 5), and return the overall error lost (Line 7). _(iii) setReferencedModel_. Algorithm 4 presents function _FD.setReferencedModel_\((\cdot)\), which consist on extracting the hyper-parameters of a given AR model \(D_{Sk}\). The underlined aim of this function is to learn the key information relative from an AR model so that it can be passed to a learner model. As it can be observed in Line 5, the properties of a reference model \(D_{Sk}\) are extracted (assuming that \(D_{Sk}\) consists of the teacher model), and yielded in Line 6 so the learner model can adopt them. _(iv) buildModel._  
Finally, Algorithm 5 shows function _MD.buildModel_\((\cdot)\), which process consists on building an AR model upon the teacher model's properties yielded by function _FD.setReferencedModel_\((D_{Sk})\), where \(D_{Sk}\) represents the \(k\)th teacher model in \(D_{S[\cdot]}\).