Integrate pytorch and scikit-learn models
Right now I use two types of models that implement incompatible APIs: HMM-style models in blocks.estimation.models
conform to scikit-learn model conventions, and neural-network-style models (in blocks.estimation.torchutils
) conform to pytorch model conventions. I want to implement a neural CRF eventually, which means my HMM-styl models need to be trainable through pytorch.
Breakdown of work to be done:
-
model.fit(data, labels)
andmodel.predict(data)
call pytorch under the hood:- initialize
dataset
anddataloader
from arguments tofit
. - train model params using
torchutils.trainModel
- call
self.forward
andself.decode
insidepredict
.
- initialize
-
self.forward(data)
uses model mixin interface-
self.forward(data)
callssuper().forward(data)
-
-
torchutils.predictBatch
checks if the model implementspredict()
Edited by Jonathan Jones