Optimization
rqequilibrium.opt
ProjectedGradientDescent
A class for performing projected gradient descent to solve optimization problems.
Attributes:
Name | Type | Description |
---|---|---|
lr |
float
|
Learning rate for the gradient descent step. |
projection |
Callable
|
Function to project the point onto a feasible set after each step. |
Methods:
Name | Description |
---|---|
step |
np.ndarray, gradients_values: np.ndarray) -> np.ndarray:
Performs a single step of projected gradient descent.
Updates the current point |
Source code in src/rqequilibrium/opt.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
step
step(w: ndarray, gradients_values: ndarray) -> np.ndarray
Perform a single step of projected gradient descent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
w
|
ndarray
|
The current point. |
required |
gradients_values
|
ndarray
|
The computed gradients at the current point. |
required |
Returns: The updated point after one step.
Source code in src/rqequilibrium/opt.py
30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
kl_divergence
kl_divergence(p: ndarray, q: ndarray) -> float
Compute the KL divergence between two probability distributions p and q.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p
|
ndarray
|
The first probability distribution. |
required |
q
|
ndarray
|
The second probability distribution. |
required |
Returns: The KL divergence between p and q.
Source code in src/rqequilibrium/opt.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
kl_reversed
kl_reversed(p: ndarray, q: ndarray) -> float
Compute the reversed KL divergence between two probability distributions p and q.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p
|
ndarray
|
The first probability distribution. |
required |
q
|
ndarray
|
The second probability distribution. |
required |
Returns: The reversed KL divergence between p and q.
Source code in src/rqequilibrium/opt.py
96 97 98 99 100 101 102 103 104 105 106 107 |
|
log_barrier
log_barrier(p: ndarray) -> float
Compute the log barrier function for a probability distribution p. Args: p (np.ndarray): The probability distribution. Returns: The log barrier value for the distribution.
Source code in src/rqequilibrium/opt.py
121 122 123 124 125 126 127 128 129 |
|
negative_entropy
negative_entropy(p: ndarray) -> float
Compute the negative entropy of a probability distribution p. Args: p (np.ndarray): The probability distribution. Returns: The negative entropy of the distribution.
Source code in src/rqequilibrium/opt.py
110 111 112 113 114 115 116 117 118 |
|
project_simplex
project_simplex(v: ndarray, s=1) -> np.ndarray
Projects a vector v onto the simplex defined by the sum of its components being equal to s. The simplex is defined as the set of vectors x such that: x >= 0 and sum(x) = s.
Taken from https://gist.github.com/daien/1272551.
Basically Implements Corollary 6.29 First Order Optimization, Amir Beck
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v
|
ndarray
|
The vector to be projected. |
required |
s
|
float
|
The sum that the components of the projected vector should equal. Default is 1. |
1
|
Returns: The projected vector onto the simplex.
Source code in src/rqequilibrium/opt.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|