你可以用 partial 从 functools 首先设置学习率和动力,然后通过这个课程 ExplicitFactorizationModel 。就像是:
partial
functools
ExplicitFactorizationModel
from functools import partial SDG_fix_lr_momentum = partial(torch.optim.SGD, lr=0.001, momentum=0.9) emodel = ExplicitFactorizationModel(n_iter=15, embedding_dim=32, use_cuda=False, loss='regression', l2=0.00005, optimizer_func=SDG_fix_lr_momentum)