diffcb 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffcb-0.1.5/LICENSE +186 -0
- diffcb-0.1.5/PKG-INFO +317 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/README.md +2 -36
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/__init__.py +1 -1
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/fft_kde.py +198 -68
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/layer.py +12 -5
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/solver.py +114 -15
- {diffcb-0.1.3 → diffcb-0.1.5}/pyproject.toml +2 -2
- diffcb-0.1.3/LICENSE +0 -21
- diffcb-0.1.3/PKG-INFO +0 -186
- {diffcb-0.1.3 → diffcb-0.1.5}/.gitignore +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/.zenodo.json +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/diagnostics.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/kde.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/dcb/utils.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/notebooks/.gitkeep +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_kde.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_layer.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_r18c_denom_audit.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_r18c_deprecation_warn.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_r19_default_fft.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_r19_diagnostics.py +0 -0
- {diffcb-0.1.3 → diffcb-0.1.5}/tests/test_solver.py +0 -0
diffcb-0.1.5/LICENSE
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
81
|
+
Contribution embodied within the Work constitutes direct or
|
|
82
|
+
contributory patent infringement, then any patent licenses granted
|
|
83
|
+
to You under this License for that Work shall terminate as of the
|
|
84
|
+
date such litigation is filed.
|
|
85
|
+
|
|
86
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
88
|
+
modifications, and in Source or Object form, provided that You
|
|
89
|
+
meet the following conditions:
|
|
90
|
+
|
|
91
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
92
|
+
Works a copy of this License; and
|
|
93
|
+
|
|
94
|
+
(b) You must cause any modified files to carry prominent notices
|
|
95
|
+
stating that You changed the files; and
|
|
96
|
+
|
|
97
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
98
|
+
that You distribute, all copyright, patent, trademark, and
|
|
99
|
+
attribution notices from the Source form of the Work,
|
|
100
|
+
excluding those notices that do not pertain to any part of
|
|
101
|
+
the Derivative Works; and
|
|
102
|
+
|
|
103
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
+
distribution, You must include a readable copy of the
|
|
105
|
+
attribution notices contained within such NOTICE file, in
|
|
106
|
+
at least one of the following places: within a NOTICE text
|
|
107
|
+
file distributed as part of the Derivative Works; within
|
|
108
|
+
the Source form or documentation, if provided along with the
|
|
109
|
+
Derivative Works; or, within a display generated by the
|
|
110
|
+
Derivative Works, if and wherever such third-party notices
|
|
111
|
+
normally appear. The contents of the NOTICE file are for
|
|
112
|
+
informational purposes only and do not modify the License.
|
|
113
|
+
You may add Your own attribution notices within Derivative
|
|
114
|
+
Works that You distribute, alongside or as an addendum to
|
|
115
|
+
the NOTICE text from the Work, provided that such additional
|
|
116
|
+
attribution notices cannot be construed as modifying the
|
|
117
|
+
License.
|
|
118
|
+
|
|
119
|
+
You may add Your own license statement for Your modifications and
|
|
120
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
121
|
+
publish, distribute, sublicense, and/or sell copies of Your
|
|
122
|
+
modifications, and to permit persons to whom Your modifications are
|
|
123
|
+
furnished to do so, as long as such licensing does not conflict with
|
|
124
|
+
the terms of this License.
|
|
125
|
+
|
|
126
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
127
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
128
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
129
|
+
this License, without any additional terms or conditions.
|
|
130
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
131
|
+
the terms of any separate license agreement you may have executed
|
|
132
|
+
with Licensor regarding such Contributions.
|
|
133
|
+
|
|
134
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
135
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
136
|
+
except as required for reasonable and customary use in describing the
|
|
137
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
138
|
+
|
|
139
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
140
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
141
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
142
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
143
|
+
implied, including, without limitation, any warranties or conditions
|
|
144
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
145
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
146
|
+
appropriateness of using or reproducing the Work and assume any
|
|
147
|
+
risks associated with Your exercise of permissions under this License.
|
|
148
|
+
|
|
149
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
150
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
151
|
+
unless required by applicable law (such as deliberate and grossly
|
|
152
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
153
|
+
liable to You for damages, including any direct, indirect, special,
|
|
154
|
+
incidental, or exemplary damages of any character arising as a
|
|
155
|
+
result of this License or out of the use or inability to use the
|
|
156
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
157
|
+
work stoppage, computer failure or malfunction, or all other
|
|
158
|
+
commercial damages or losses), even if such Contributor has been
|
|
159
|
+
advised of the possibility of such damages.
|
|
160
|
+
|
|
161
|
+
9. Accepting Warranty or Liability. While redistributing the Work or
|
|
162
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
163
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
164
|
+
obligations and/or rights consistent with this License. However, in
|
|
165
|
+
accepting such obligations, You may offer such obligations only on
|
|
166
|
+
Your own behalf and on Your sole responsibility, not on behalf of
|
|
167
|
+
any other Contributor, and only if You agree to indemnify, defend,
|
|
168
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
169
|
+
or claims asserted against, such Contributor by reason of your
|
|
170
|
+
accepting any such warranty or additional liability.
|
|
171
|
+
|
|
172
|
+
END OF TERMS AND CONDITIONS
|
|
173
|
+
|
|
174
|
+
Copyright 2026 Ruiyu Zhang
|
|
175
|
+
|
|
176
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
177
|
+
you may not use this file except in compliance with the License.
|
|
178
|
+
You may obtain a copy of the License at
|
|
179
|
+
|
|
180
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
181
|
+
|
|
182
|
+
Unless required by applicable law or agreed to in writing, software
|
|
183
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
184
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
185
|
+
See the License for the specific language governing permissions and
|
|
186
|
+
limitations under the License.
|
diffcb-0.1.5/PKG-INFO
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: diffcb
|
|
3
|
+
Version: 0.1.5
|
|
4
|
+
Summary: Differentiable Critical Bandwidth: Silverman's modality test as a differentiable PyTorch layer with IFT backward pass.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ryZhangHason/differentiable-critical-bandwidth
|
|
6
|
+
Project-URL: Repository, https://github.com/ryZhangHason/differentiable-critical-bandwidth
|
|
7
|
+
Project-URL: Documentation, https://github.com/ryZhangHason/differentiable-critical-bandwidth#readme
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/ryZhangHason/differentiable-critical-bandwidth/issues
|
|
9
|
+
Author-email: Ruiyu Zhang <dhhhason@gmail.com>
|
|
10
|
+
License: Apache License
|
|
11
|
+
Version 2.0, January 2004
|
|
12
|
+
http://www.apache.org/licenses/
|
|
13
|
+
|
|
14
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
15
|
+
|
|
16
|
+
1. Definitions.
|
|
17
|
+
|
|
18
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
19
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
20
|
+
|
|
21
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
22
|
+
the copyright owner that is granting the License.
|
|
23
|
+
|
|
24
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
25
|
+
other entities that control, are controlled by, or are under common
|
|
26
|
+
control with that entity. For the purposes of this definition,
|
|
27
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
28
|
+
direction or management of such entity, whether by contract or
|
|
29
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
30
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
31
|
+
|
|
32
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
33
|
+
exercising permissions granted by this License.
|
|
34
|
+
|
|
35
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
36
|
+
including but not limited to software source code, documentation
|
|
37
|
+
source, and configuration files.
|
|
38
|
+
|
|
39
|
+
"Object" form shall mean any form resulting from mechanical
|
|
40
|
+
transformation or translation of a Source form, including but
|
|
41
|
+
not limited to compiled object code, generated documentation,
|
|
42
|
+
and conversions to other media types.
|
|
43
|
+
|
|
44
|
+
"Work" shall mean the work of authorship made available under
|
|
45
|
+
the License, as indicated by a copyright notice that is included in
|
|
46
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
47
|
+
|
|
48
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
49
|
+
form, that is based on (or derived from) the Work and for which the
|
|
50
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
51
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
52
|
+
of this License, Derivative Works shall not include works that remain
|
|
53
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
54
|
+
the Work and Derivative Works thereof.
|
|
55
|
+
|
|
56
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
57
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
58
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
59
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
60
|
+
or written communication sent to the Licensor or its representatives,
|
|
61
|
+
including but not limited to communication on electronic mailing lists,
|
|
62
|
+
source code control systems, and issue tracking systems that are managed
|
|
63
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
64
|
+
improving the Work, but excluding communication that is conspicuously
|
|
65
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
66
|
+
Contribution."
|
|
67
|
+
|
|
68
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
69
|
+
whom a Contribution has been received by the Licensor and included
|
|
70
|
+
within the Work.
|
|
71
|
+
|
|
72
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
73
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
74
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
75
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
76
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
77
|
+
Work and such Derivative Works in Source or Object form.
|
|
78
|
+
|
|
79
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
(except as stated in this section) patent license to make, have made,
|
|
83
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
84
|
+
where such license applies only to those patent claims licensable
|
|
85
|
+
by such Contributor that are necessarily infringed by their
|
|
86
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
87
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
88
|
+
institute patent litigation against any entity (including a cross-claim
|
|
89
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
90
|
+
Contribution embodied within the Work constitutes direct or
|
|
91
|
+
contributory patent infringement, then any patent licenses granted
|
|
92
|
+
to You under this License for that Work shall terminate as of the
|
|
93
|
+
date such litigation is filed.
|
|
94
|
+
|
|
95
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
96
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
97
|
+
modifications, and in Source or Object form, provided that You
|
|
98
|
+
meet the following conditions:
|
|
99
|
+
|
|
100
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
101
|
+
Works a copy of this License; and
|
|
102
|
+
|
|
103
|
+
(b) You must cause any modified files to carry prominent notices
|
|
104
|
+
stating that You changed the files; and
|
|
105
|
+
|
|
106
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
107
|
+
that You distribute, all copyright, patent, trademark, and
|
|
108
|
+
attribution notices from the Source form of the Work,
|
|
109
|
+
excluding those notices that do not pertain to any part of
|
|
110
|
+
the Derivative Works; and
|
|
111
|
+
|
|
112
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
113
|
+
distribution, You must include a readable copy of the
|
|
114
|
+
attribution notices contained within such NOTICE file, in
|
|
115
|
+
at least one of the following places: within a NOTICE text
|
|
116
|
+
file distributed as part of the Derivative Works; within
|
|
117
|
+
the Source form or documentation, if provided along with the
|
|
118
|
+
Derivative Works; or, within a display generated by the
|
|
119
|
+
Derivative Works, if and wherever such third-party notices
|
|
120
|
+
normally appear. The contents of the NOTICE file are for
|
|
121
|
+
informational purposes only and do not modify the License.
|
|
122
|
+
You may add Your own attribution notices within Derivative
|
|
123
|
+
Works that You distribute, alongside or as an addendum to
|
|
124
|
+
the NOTICE text from the Work, provided that such additional
|
|
125
|
+
attribution notices cannot be construed as modifying the
|
|
126
|
+
License.
|
|
127
|
+
|
|
128
|
+
You may add Your own license statement for Your modifications and
|
|
129
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
130
|
+
publish, distribute, sublicense, and/or sell copies of Your
|
|
131
|
+
modifications, and to permit persons to whom Your modifications are
|
|
132
|
+
furnished to do so, as long as such licensing does not conflict with
|
|
133
|
+
the terms of this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or reproducing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or exemplary damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or all other
|
|
167
|
+
commercial damages or losses), even if such Contributor has been
|
|
168
|
+
advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Liability. While redistributing the Work or
|
|
171
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
172
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
173
|
+
obligations and/or rights consistent with this License. However, in
|
|
174
|
+
accepting such obligations, You may offer such obligations only on
|
|
175
|
+
Your own behalf and on Your sole responsibility, not on behalf of
|
|
176
|
+
any other Contributor, and only if You agree to indemnify, defend,
|
|
177
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
178
|
+
or claims asserted against, such Contributor by reason of your
|
|
179
|
+
accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
Copyright 2026 Ruiyu Zhang
|
|
184
|
+
|
|
185
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
186
|
+
you may not use this file except in compliance with the License.
|
|
187
|
+
You may obtain a copy of the License at
|
|
188
|
+
|
|
189
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
190
|
+
|
|
191
|
+
Unless required by applicable law or agreed to in writing, software
|
|
192
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
193
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
194
|
+
See the License for the specific language governing permissions and
|
|
195
|
+
limitations under the License.
|
|
196
|
+
License-File: LICENSE
|
|
197
|
+
Keywords: PyTorch,anomaly detection,critical bandwidth,differentiable programming,generative models,kernel density estimation,mode counting,nonparametric statistics
|
|
198
|
+
Classifier: Development Status :: 3 - Alpha
|
|
199
|
+
Classifier: Intended Audience :: Science/Research
|
|
200
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
201
|
+
Classifier: Programming Language :: Python :: 3
|
|
202
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
203
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
204
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
205
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
206
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
207
|
+
Requires-Python: >=3.9
|
|
208
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
209
|
+
Requires-Dist: numpy>=1.24.0
|
|
210
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
211
|
+
Requires-Dist: scipy>=1.10.0
|
|
212
|
+
Requires-Dist: torch>=2.0.0
|
|
213
|
+
Provides-Extra: dev
|
|
214
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
215
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
216
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
217
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
218
|
+
Provides-Extra: notebooks
|
|
219
|
+
Requires-Dist: ipywidgets>=8.0.0; extra == 'notebooks'
|
|
220
|
+
Requires-Dist: jupyter>=1.0.0; extra == 'notebooks'
|
|
221
|
+
Description-Content-Type: text/markdown
|
|
222
|
+
|
|
223
|
+
# DCB — Differentiable Critical Bandwidth
|
|
224
|
+
|
|
225
|
+
[](https://pypi.org/project/diffcb/)
|
|
226
|
+
[](LICENSE)
|
|
227
|
+
[](https://www.python.org/)
|
|
228
|
+
|
|
229
|
+
A PyTorch package that makes **Silverman's critical bandwidth test (1981)** fully differentiable, enabling end-to-end gradient-based optimization over the modal structure of continuous distributions.
|
|
230
|
+
|
|
231
|
+
## Overview
|
|
232
|
+
|
|
233
|
+
The critical bandwidth `h_crit` is the minimum KDE bandwidth at which a distribution appears to have at most `m` modes — a classical nonparametric statistic for modality testing. DCB replaces every non-differentiable operation in its computation with a smooth surrogate, then uses the **Implicit Function Theorem** to compute exact gradients through the root-finding step at O(1) memory cost.
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
import torch
|
|
237
|
+
from dcb import DCBLayer
|
|
238
|
+
|
|
239
|
+
X = torch.randn(1000, requires_grad=True) # 1D samples
|
|
240
|
+
layer = DCBLayer(target_modes=1)
|
|
241
|
+
h_crit = layer(X) # differentiable scalar
|
|
242
|
+
h_crit.backward() # exact IFT gradients
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Installation
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
pip install diffcb
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Or from source:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
git clone https://github.com/ryZhangHason/differentiable-critical-bandwidth
|
|
255
|
+
cd differentiable-critical-bandwidth
|
|
256
|
+
pip install -e ".[dev]"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Accuracy vs R's `bw.crit`
|
|
260
|
+
|
|
261
|
+
DCB is validated against R's `multimode::bw.crit(data, mod0=1)` — the standard reference implementation of Hall & York (2001). On **identical data**:
|
|
262
|
+
|
|
263
|
+
| n | DCB vs R (same sample) | DCB vs R (independent samples) |
|
|
264
|
+
|---|---|---|
|
|
265
|
+
| 100K | **0.004%** | ~0.5% (MC noise from independent RNG) |
|
|
266
|
+
| 1M | **0.005%** | ~0.2% |
|
|
267
|
+
| 10M | **0.004%** | ~0.1% |
|
|
268
|
+
|
|
269
|
+
The independent-sample figures reflect natural sampling variability (two unbiased estimators drawing different data), not algorithmic error. On identical data, DCB agrees with R to within **0.005%** at all tested n. DCB is 43× faster than R at n=100M (1.1 s vs 50 s) and handles n=2B in 24 s while R OOMs.
|
|
270
|
+
|
|
271
|
+
## Key Parameters
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
DCBLayer(
|
|
275
|
+
target_modes=1, # target number of modes
|
|
276
|
+
G=512, # IFT evaluation grid points
|
|
277
|
+
use_fft=True, # FFT forward (default); eliminates subsampling bias for n>50K
|
|
278
|
+
max_n_exact=1_000_000,# sketch to sketch_size when n exceeds this (None = always exact)
|
|
279
|
+
sketch_size=500_000, # sketch target; 500K matches full-n accuracy (O(n^{-2/9}) rate)
|
|
280
|
+
safe_backward=False, # clamp IFT denominator near bifurcations
|
|
281
|
+
)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Confirmed Experimental Results
|
|
285
|
+
|
|
286
|
+
All GPU results produced on Kaggle (T4 / P100) — see `experiments/` and `outputs/`.
|
|
287
|
+
|
|
288
|
+
| Experiment | Result | Criterion |
|
|
289
|
+
|---|---|---|
|
|
290
|
+
| **Accuracy vs R (same data, n=100K)** | **0.004%** | < 0.01% ✓ |
|
|
291
|
+
| **Validation (m≥2, Marron-Wand)** | R²=0.91, MAE=0.07, ρ=0.89 | R²≥0.85 ✓ |
|
|
292
|
+
| **Speedup vs scipy (CUDA T4, n=8192)** | **10.5×** | ≥3× ✓ |
|
|
293
|
+
| **GAN mode preservation** | h_crit=1.232 >> 0.3 | h_crit>0.3 ✓ |
|
|
294
|
+
| **Anomaly AUC (KDDCup99)** | DCB=**0.9982** vs IF=0.9867 | DCB≥IF ✓ |
|
|
295
|
+
|
|
296
|
+
## Repository Structure
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
dcb/ Core PyTorch package
|
|
300
|
+
layer.py DCBLayer nn.Module + DCBFunction autograd
|
|
301
|
+
solver.py IFT root-finder and backward pass
|
|
302
|
+
fft_kde.py FFT-based mode counter (MPS-safe, float64, G=16384)
|
|
303
|
+
kde.py Direct KDE derivatives (small-n path)
|
|
304
|
+
utils.py Grid, Silverman bandwidth, sg() stabilizer
|
|
305
|
+
experiments/ Reproduction scripts for all paper figures and tables
|
|
306
|
+
phase1_*.py Validation, speedup, ablation (Figures 1–2, S1–S2)
|
|
307
|
+
phase2_gan.py GAN mode-collapse prevention (Figure 3)
|
|
308
|
+
phase3_anomaly.py Anomaly detection (Table 2, Figure 5)
|
|
309
|
+
round20_*.py Large-n R comparison and streaming benchmarks
|
|
310
|
+
round21_*.py Accuracy improvement experiments
|
|
311
|
+
tests/ Unit tests (pytest, 45 passed, 1 xfailed)
|
|
312
|
+
outputs/ All generated figures and tables (PDFs, PNGs, CSVs)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# DCB — Differentiable Critical Bandwidth
|
|
2
2
|
|
|
3
3
|
[](https://pypi.org/project/diffcb/)
|
|
4
|
-
[](LICENSE)
|
|
5
5
|
[](https://www.python.org/)
|
|
6
6
|
|
|
7
7
|
A PyTorch package that makes **Silverman's critical bandwidth test (1981)** fully differentiable, enabling end-to-end gradient-based optimization over the modal structure of continuous distributions.
|
|
@@ -71,18 +71,6 @@ All GPU results produced on Kaggle (T4 / P100) — see `experiments/` and `outpu
|
|
|
71
71
|
| **GAN mode preservation** | h_crit=1.232 >> 0.3 | h_crit>0.3 ✓ |
|
|
72
72
|
| **Anomaly AUC (KDDCup99)** | DCB=**0.9982** vs IF=0.9867 | DCB≥IF ✓ |
|
|
73
73
|
|
|
74
|
-
## Changelog
|
|
75
|
-
|
|
76
|
-
### v0.1.1 (2026-05-29)
|
|
77
|
-
- **MPS fix:** `torch.histc` on MPS allocated an n×bins intermediate (OOM at n≥5M). Replaced with `bucketize+bincount` on CPU — MPS-safe and numerically identical.
|
|
78
|
-
- **Sketch API:** `DCBLayer(max_n_exact=1_000_000, sketch_size=500_000)` — silently sketches to 500K when n exceeds threshold. Justified by O(n⁻²/⁹) convergence of h_crit; 500K sketch matches full-n accuracy.
|
|
79
|
-
- **Consistent bisection domain:** Pre-computed domain passed to all `fft_mode_count` calls in a single bisection, eliminating per-step drift.
|
|
80
|
-
- **Bias warning direction:** Corrected "expected upward bias" to "expected downward bias" on legacy `use_fft=False` path.
|
|
81
|
-
- **Test fixes:** Updated 8 pre-existing test failures (tuple unpacking, bounds, deprecation API).
|
|
82
|
-
|
|
83
|
-
### v0.1.0 (2026-05-28)
|
|
84
|
-
- Initial PyPI release. FFT forward (O(n + G log G)), IFT backward, MPS support.
|
|
85
|
-
|
|
86
74
|
## Repository Structure
|
|
87
75
|
|
|
88
76
|
```
|
|
@@ -102,28 +90,6 @@ tests/ Unit tests (pytest, 45 passed, 1 xfailed)
|
|
|
102
90
|
outputs/ All generated figures and tables (PDFs, PNGs, CSVs)
|
|
103
91
|
```
|
|
104
92
|
|
|
105
|
-
## Reproducing Paper Results
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# Phase 1: validation, speedup, ablation
|
|
109
|
-
python experiments/phase1_validation.py
|
|
110
|
-
python experiments/phase1_speedup.py
|
|
111
|
-
|
|
112
|
-
# Phase 2: GAN mode collapse experiment
|
|
113
|
-
python experiments/phase2_gan.py
|
|
114
|
-
|
|
115
|
-
# Phase 3: anomaly detection benchmark
|
|
116
|
-
python experiments/phase3_anomaly.py
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
For GPU runs use the Kaggle kernels:
|
|
120
|
-
- Phase 1–2: `hsingle/dcb-full-experiments`
|
|
121
|
-
- Phase 3: `hsingle/dcb-phase-3-anomaly-detection`
|
|
122
|
-
|
|
123
|
-
## Paper
|
|
124
|
-
|
|
125
|
-
> Ruiyu Zhang. "Differentiable Critical Bandwidth: Making Silverman's Modality Test End-to-End Trainable." *Journal of Machine Learning Research*, 2026 (in preparation).
|
|
126
|
-
|
|
127
93
|
## License
|
|
128
94
|
|
|
129
|
-
|
|
95
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|