Thank you very much for your reply. After check RootAlign.paramters(), I’d say that RootAlign does have the parameters of RecursiveNN. Yet I don’t understand why the model can’t be well trained. The train function shows as follow:
for _data in snli.train:
            p_tree = _data['p_tree']
            h_tree = _data['h_tree']
            target = Variable(torch.LongTensor([_data['label']]))
            optimizer.zero_grad()
            output = root_align(p_tree, h_tree)
            loss = F.nll_loss(output, target)
            loss.backward()
            optimizer.step()
            train_loss += loss

And, the whole project can be obtained at [here] 5. The train function can be found in “train.py”
By the way, I don’t know how to cache node.calculate_result. Can you please show me an example?
Thank you again for your help.