Search code examples
pythonmachine-learningmetal

Metal train got an unexpected keyword argument 'n_epochs'


I am writing a Python code and in this part of the code, I want to use Metal to train my Model, like here:

from metal.label_model import LabelModel
gen_model = LabelModel()
%time gen_model.train(L_train[0], n_epochs=500, print_every=100)

But that gives:

TypeError                                 
Traceback (most recent call last)
<timed eval> in <module>

TypeError: train() got an unexpected keyword argument 'n_epochs'

Solution

  • In 0.3.0 there's a change:

    'Renames Classifier.train to Classifier.train_model to avoid overwriting the nn.Module.train function'

    So try using train_model() instead of train():

    from metal.label_model import LabelModel
    gen_model = LabelModel()
    %time gen_model.train_model(L_train[0], n_epochs=500, print_every=100)
    

    Source:

    https://github.com/HazyResearch/metal/commit/4210c7c66f3f4a6fc7287192aec133c293ed8198