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

Method __init__

bitsandbytes/optim/sgd.py:9–56  ·  view source on GitHub ↗

Base 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 optimiz

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

Source from the content-addressed store, hash-verified

7
8class SGD(Optimizer1State):
9 def __init__(
10 self,
11 params,
12 lr,
13 momentum=0,
14 dampening=0,
15 weight_decay=0,
16 nesterov=False,
17 optim_bits=32,
18 args=None,
19 min_8bit_size=4096,
20 ):
21 """
22 Base SGD optimizer.
23
24 Arguments:
25 params (`torch.tensor`):
26 The input parameters to optimize.
27 lr (`float`):
28 The learning rate.
29 momentum (`float`, defaults to 0):
30 The momentum value speeds up the optimizer by taking bigger steps.
31 dampening (`float`, defaults to 0):
32 The dampening value reduces the momentum of the optimizer.
33 weight_decay (`float`, defaults to 0.0):
34 The weight decay value for the optimizer.
35 nesterov (`bool`, defaults to `False`):
36 Whether to use Nesterov momentum.
37 optim_bits (`int`, defaults to 32):
38 The number of bits of the optimizer state.
39 args (`object`, defaults to `None`):
40 An object with additional arguments.
41 min_8bit_size (`int`, defaults to 4096):
42 The minimum number of elements of the parameter tensors for 8-bit optimization.
43 """
44 if momentum == 0:
45 raise NotImplementedError("SGD without momentum is not supported!")
46 super().__init__(
47 "momentum",
48 params,
49 lr,
50 (momentum, dampening),
51 0.0,
52 weight_decay,
53 optim_bits,
54 args,
55 min_8bit_size,
56 )
57
58
59class SGD8bit(Optimizer1State):

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected