mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE]: Apply FURB118 (prev): replaces unnecessary lambdas with operator. (#116027)
This replaces a bunch of unnecessary lambdas with the operator package. This is semantically equivalent, but the operator package is faster, and arguably more readable. When the FURB rules are taken out of preview, I will enable it as a ruff check. Pull Request resolved: https://github.com/pytorch/pytorch/pull/116027 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
2d2016fdf8
commit
6de28e92d2
@ -1,3 +1,4 @@
|
||||
import operator
|
||||
import threading
|
||||
import time
|
||||
from functools import reduce
|
||||
@ -75,9 +76,7 @@ class AgentBase:
|
||||
batch (bool): Whether to process and respond to observer requests as a batch or 1 at a time
|
||||
"""
|
||||
self.batch = batch
|
||||
self.policy = Policy(
|
||||
reduce((lambda x, y: x * y), state_size), nlayers, out_features
|
||||
)
|
||||
self.policy = Policy(reduce(operator.mul, state_size), nlayers, out_features)
|
||||
self.optimizer = optim.Adam(self.policy.parameters(), lr=1e-2)
|
||||
|
||||
self.batch_size = batch_size
|
||||
|
Reference in New Issue
Block a user