Skip to content

how to save tsai model and load in libtorch C++ #951

@MichaelCarrik

Description

@MichaelCarrik
  1. I am trainning model in python like this

            model= tsai.LSTM_FCNPlus(train_dsets.vars, train_dsets.c, train_dsets.len, se=8)
            learn = tsai.Learner(train_dsets, model, metrics=[tsai.mae, tsai.rmse])
            learn.fit(80, learnRate *0.9,cbs=[EarlyStoppingCallback(patience=7), ShowGraphCallback()]
                       )
           torch.jit.trace(model,).save("model.pt")
           predict1 =  learn.get_X_preds(inputs)
    
  2. I load model which step 1 save in libtorch c++ like this

    module = torch::jit::load("model.pt");
    predict2 =   module.forward(inputs).toTensor();
    

I can ensure they have same weights.
however predict1 is not same as predict2 . can anyone tell me correct way  how to save tsai model and load in c++, appreciatlly

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions