Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before switch to SpeechBrain, how to use trained model in pytorch #254

Open
sun-peach opened this issue Apr 9, 2021 · 0 comments
Open

Comments

@sun-peach
Copy link

sun-peach commented Apr 9, 2021

Hi, I know we have new framework SpeechBrain now (which is very fantastic), but I still have old model trained with pytorch-kaldi. I would like to use it in Pytorch now. But when I verify the result, I found the results from Pytorch code and pytorch-kaldi are very different.

My pytorch kaldi is as below:

class BasePhModel(Module):
    def __init__(self, options):
        super(BasePhModel, self).__init__()
        cfg_file = options["cfg"]        # the cfg file is the same one when I trained the model
        config = configparser.ConfigParser()
        config.read(cfg_file)
        config["architecture1"]["to_do"] = "forward"
        config["architecture1"]["use_cuda"] = "False"
        config["architecture2"]["to_do"] = "forward"
        config["architecture2"]["use_cuda"] = "False"
        model1_file = options["architecture1_file"]
        model2_file = options["architecture2_file"]
        self.model1 = GRU(config["architecture1"], 16)    # I use GRU + MLP in my .conf file
        self.model2 = MLP(config["architecture2"], 1024)
        self.model1.load_state_dict(torch.load(model1_file)["model_par"])
        self.model2.load_state_dict(torch.load(model2_file)["model_par"])

    def forward(self, x):
        intermediate = self.model1(x)
        y = self.model2(intermediate)
        return y

when I use the same feature input to this model, the result is very different from the one in "forward_*_decode.ark". Is there any thing wrong with my code?

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant