thanks for the share. But in my case is a little different.
I create a tensor not a module that need to track the grad,and wanna set different lr of that tensor.But I got problem when “params_groups.push_back(tensor)”,how can I fix it?
    torch::Tensor actionLogSTD;//that is the problem
    actionLogSTD = register_parameter("actionLogSTD", torch::zeros((1, actionDim)) - 0.5);//require_grad=true

    auto& params_groups = p_optimizer->param_groups();
    p_optimizer->parameters().push_back((*p_actor)->actionLogSTD);
    params_groups.push_back(torch::optim::OptimizerParamGroup((*p_sharedBILSTM)->parameters()));
    params_groups.push_back(torch::optim::OptimizerParamGroup((*p_actor)->actor_fc_net1->parameters()));
    params_groups.push_back(torch::optim::OptimizerParamGroup((*p_critic)->critic_fc_net1->parameters()));
    params_groups.push_back(torch::optim::OptimizerParamGroup((*p_critic)->actionLogSTD));//this lead to error,tensor type not matching OptimizerParamGroup type
    for (auto param_group : p_optimizer->param_groups())
        static_cast<torch::optim::AdamOptions &>(param_group.options()).lr(lr);