Minor fixes
This commit is contained in:
parent
f09296cf78
commit
9d5fa59584
5 changed files with 5922 additions and 18962 deletions
File diff suppressed because one or more lines are too long
|
|
@ -17,11 +17,11 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
|
"import sys\n",
|
||||||
|
"sys.path.insert(0, \"../../\")\n",
|
||||||
|
"\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
"import sys\n",
|
|
||||||
"\n",
|
|
||||||
"sys.path.insert(0, \"../../\")\n",
|
|
||||||
"from editor.operations import get_random_saturation_per_hue_lut\n",
|
"from editor.operations import get_random_saturation_per_hue_lut\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.12.2"
|
"version": "3.1.-1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@ from .random import random
|
||||||
from .compute_histogram import compute_histogram
|
from .compute_histogram import compute_histogram
|
||||||
from .generate_rotation_matrices import generate_rotation_matrices
|
from .generate_rotation_matrices import generate_rotation_matrices
|
||||||
from .get_next_run_name import get_next_run_name
|
from .get_next_run_name import get_next_run_name
|
||||||
|
from .kldiv import kldiv
|
||||||
|
|
|
||||||
11
src/editor/utils/kldiv.py
Normal file
11
src/editor/utils/kldiv.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def kldiv(P: np.ndarray, Q: np.ndarray) -> float:
|
||||||
|
P /= P.sum()
|
||||||
|
Q /= Q.sum()
|
||||||
|
|
||||||
|
P_safe = np.maximum(P, np.finfo(float).eps)
|
||||||
|
Q_safe = np.maximum(Q, np.finfo(float).eps)
|
||||||
|
|
||||||
|
return np.sum(P_safe * np.log(P_safe / Q_safe))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue