MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / __init__

Method __init__

bitsandbytes/optim/sgd.py:60–104  ·  view source on GitHub ↗

8-bit SGD optimizer. Arguments: params (`torch.tensor`): The input parameters to optimize. lr (`float`): The learning rate. momentum (`float`, defaults to 0): The momentum value speeds up the optimi

(
        self,
        params,
        lr,
        momentum=0,
        dampening=0,
        weight_decay=0,
        nesterov=False,
        args=None,
        min_8bit_size=4096,
    )

Source from the content-addressed store, hash-verified

58
59class SGD8bit(Optimizer1State):
60 def __init__(
61 self,
62 params,
63 lr,
64 momentum=0,
65 dampening=0,
66 weight_decay=0,
67 nesterov=False,
68 args=None,
69 min_8bit_size=4096,
70 ):
71 """
72 8-bit SGD optimizer.
73
74 Arguments:
75 params (`torch.tensor`):
76 The input parameters to optimize.
77 lr (`float`):
78 The learning rate.
79 momentum (`float`, defaults to 0):
80 The momentum value speeds up the optimizer by taking bigger steps.
81 dampening (`float`, defaults to 0):
82 The dampening value reduces the momentum of the optimizer.
83 weight_decay (`float`, defaults to 0.0):
84 The weight decay value for the optimizer.
85 nesterov (`bool`, defaults to `False`):
86 Whether to use Nesterov momentum.
87 args (`object`, defaults to `None`):
88 An object with additional arguments.
89 min_8bit_size (`int`, defaults to 4096):
90 The minimum number of elements of the parameter tensors for 8-bit optimization.
91 """
92 if momentum == 0:
93 raise NotImplementedError("SGD without momentum is not supported!")
94 super().__init__(
95 "momentum",
96 params,
97 lr,
98 (momentum, dampening),
99 0.0,
100 weight_decay,
101 8,
102 args,
103 min_8bit_size,
104 )
105
106
107class SGD32bit(Optimizer1State):

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected