CUQIpy 1.2.0.post0.dev15__py3-none-any.whl → 1.2.0.post0.dev30__py3-none-any.whl

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.

Potentially problematic release.


This version of CUQIpy might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CUQIpy
3
- Version: 1.2.0.post0.dev15
3
+ Version: 1.2.0.post0.dev30
4
4
  Summary: Computational Uncertainty Quantification for Inverse problems in Python
5
5
  Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
6
6
  License: Apache License
@@ -231,8 +231,9 @@ CUQIpy is part of the [CUQI project](https://www.compute.dtu.dk/english/cuqi) su
231
231
 
232
232
  - **Papers:** CUQIpy on ArXiv - [Part I](https://arxiv.org/abs/2305.16949) & [Part II](https://arxiv.org/abs/2305.16951)
233
233
 
234
- - **Training:** [Demo & training notebooks](https://github.com/CUQI-DTU/CUQIpy-demos)
234
+ - **CUQI book:** [CUQI book website](https://cuqi-dtu.github.io/CUQI-Book/)
235
235
 
236
+ - **User showcases:** [Showcase repository](https://github.com/CUQI-DTU/CUQIpy-User-Showcase/)
236
237
 
237
238
  ## 🚀 Quickstart
238
239
  Install CUQIpy using pip:
@@ -1,6 +1,6 @@
1
1
  cuqi/__init__.py,sha256=LsGilhl-hBLEn6Glt8S_l0OJzAA1sKit_rui8h-D-p0,488
2
2
  cuqi/_messages.py,sha256=fzEBrZT2kbmfecBBPm7spVu7yHdxGARQB4QzXhJbCJ0,415
3
- cuqi/_version.py,sha256=jnnRtB8exI7lWU5EPo-fzA3hR7cN_F8fP6jeWSCwWEk,509
3
+ cuqi/_version.py,sha256=QJEhKLIZcwiFhDOxL5fW3HoGva9HIMdu-ceQvUCHsjs,509
4
4
  cuqi/config.py,sha256=wcYvz19wkeKW2EKCGIKJiTpWt5kdaxyt4imyRkvtTRA,526
5
5
  cuqi/diagnostics.py,sha256=5OrbJeqpynqRXOe5MtOKKhe7EAVdOEpHIqHnlMW9G_c,3029
6
6
  cuqi/array/__init__.py,sha256=-EeiaiWGNsE3twRS4dD814BIlfxEsNkTCZUc5gjOXb0,30
@@ -40,13 +40,13 @@ cuqi/experimental/mcmc/_conjugate_approx.py,sha256=uEnY2ea9su5ivcNagyRAwpQP2gBY9
40
40
  cuqi/experimental/mcmc/_cwmh.py,sha256=50v3uZaWhlVnfrEB5-lB_7pn8QoUVBe-xWxKGKbmNHg,7234
41
41
  cuqi/experimental/mcmc/_direct.py,sha256=9pQS_2Qk2-ybt6m8WTfPoKetcxQ00WaTRN85-Z0FrBY,777
42
42
  cuqi/experimental/mcmc/_gibbs.py,sha256=a_Zr007F233R6A3CJ_0zlQppsQrVuX8-oWCbNJWJxmA,12745
43
- cuqi/experimental/mcmc/_hmc.py,sha256=2MuU-fWvun0bmt1niFLL7iIHbtwubI2b-MHRykWDjwM,19548
43
+ cuqi/experimental/mcmc/_hmc.py,sha256=AR8ucnjPe9Q78em3IMoihLoifdBxu9oAjrQ51AYPHH4,19390
44
44
  cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=yNO7ABxmkixzcLG-lv57GOTyeTr7HwFs2DrrhuZW9OI,8398
45
45
  cuqi/experimental/mcmc/_laplace_approximation.py,sha256=rdiE3cMQFq6FLQcOQwPpuGIxrTAp3aoGPxMDSdeopV0,5688
46
46
  cuqi/experimental/mcmc/_mh.py,sha256=MXo0ahXP4KGFkaY4HtvcBE-TMQzsMlTmLKzSvpz7drU,2941
47
47
  cuqi/experimental/mcmc/_pcn.py,sha256=wqJBZLuRFSwxihaI53tumAg6AWVuceLMOmXssTetd1A,3374
48
48
  cuqi/experimental/mcmc/_rto.py,sha256=OtzgiYCxDoTdXp7y4mkLa2upj74qadesoqHYpr11ZCg,10061
49
- cuqi/experimental/mcmc/_sampler.py,sha256=S7sY7ORAPz2d7lvUhCRSg1PCbC745YXn4KVIqRYAZtw,20040
49
+ cuqi/experimental/mcmc/_sampler.py,sha256=lWb0ORdkYcVkZ6G0ypHfmrWXZPfaXnsUj1wAncKxa7g,20339
50
50
  cuqi/experimental/mcmc/_utilities.py,sha256=kUzHbhIS3HYZRbneNBK41IogUYX5dS_bJxqEGm7TQBI,525
51
51
  cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
52
52
  cuqi/geometry/_geometry.py,sha256=SDRZdiN2CIuS591lXxqgFoPWPIpwY-MHk75116QvdYY,46901
@@ -85,8 +85,8 @@ cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7s
85
85
  cuqi/utilities/__init__.py,sha256=H7xpJe2UinjZftKvE2JuXtTi4DqtkR6uIezStAXwfGg,428
86
86
  cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
87
87
  cuqi/utilities/_utilities.py,sha256=Jc4knn80vLoA7kgw9FzXwKVFGaNBOXiA9kgvltZU3Ao,11777
88
- CUQIpy-1.2.0.post0.dev15.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
89
- CUQIpy-1.2.0.post0.dev15.dist-info/METADATA,sha256=AjFHjLR2ychxpFCl7bziruEmKwSf0O8mpLd_jHCZ4wg,18410
90
- CUQIpy-1.2.0.post0.dev15.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
91
- CUQIpy-1.2.0.post0.dev15.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
92
- CUQIpy-1.2.0.post0.dev15.dist-info/RECORD,,
88
+ CUQIpy-1.2.0.post0.dev30.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
89
+ CUQIpy-1.2.0.post0.dev30.dist-info/METADATA,sha256=lPVBe_Ad6ghqiE2CkcVDyABxmJ8Hb610VL0cZSxmVeo,18495
90
+ CUQIpy-1.2.0.post0.dev30.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
91
+ CUQIpy-1.2.0.post0.dev30.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
92
+ CUQIpy-1.2.0.post0.dev30.dist-info/RECORD,,
cuqi/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-09-30T18:06:47+0200",
11
+ "date": "2024-10-11T09:05:14+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "59a6730dfe1227a35a2def467daf63265bdba87f",
15
- "version": "1.2.0.post0.dev15"
14
+ "full-revisionid": "e46192df9743f4e53f2ad126462ed1fd95a97dd0",
15
+ "version": "1.2.0.post0.dev30"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -109,10 +109,7 @@ class NUTS(Sampler):
109
109
 
110
110
  def _initialize(self):
111
111
 
112
- # Arrays to store acceptance rate
113
- self._acc = [None] # Overwrites acc from Sampler. TODO. Check if this is necessary
114
-
115
- self._current_alpha_ratio = np.nan # Current alpha ratio is set to some
112
+ self._current_alpha_ratio = np.nan # Current alpha ratio will be set to some
116
113
  # value (other than np.nan) before
117
114
  # being used
118
115
 
@@ -233,6 +230,7 @@ class NUTS(Sampler):
233
230
  r_minus, r_plus = np.copy(r_k), np.copy(r_k)
234
231
 
235
232
  # run NUTS
233
+ acc = 0
236
234
  while (s == 1) and (j <= self.max_depth):
237
235
  # sample a direction
238
236
  v = int(2*(np.random.rand() < 0.5)-1)
@@ -260,9 +258,8 @@ class NUTS(Sampler):
260
258
  self.current_point = point_prime
261
259
  self.current_target_logd = logd_prime
262
260
  self.current_target_grad = np.copy(grad_prime)
263
- self._acc.append(1)
264
- else:
265
- self._acc.append(0)
261
+ acc = 1
262
+
266
263
 
267
264
  # update number of particles, tree level, and stopping criterion
268
265
  n += n_prime
@@ -280,6 +277,8 @@ class NUTS(Sampler):
280
277
  if np.isnan(self.current_target_logd):
281
278
  raise NameError('NaN potential func')
282
279
 
280
+ return acc
281
+
283
282
  def tune(self, skip_len, update_count):
284
283
  """ adapt epsilon during burn-in using dual averaging"""
285
284
  k = update_count+1
@@ -220,7 +220,8 @@ class Sampler(ABC):
220
220
  if hasattr(self, "_pre_sample"): self._pre_sample()
221
221
 
222
222
  # Draw samples
223
- for _ in tqdm( range(Ns), "Sample: "):
223
+ pbar = tqdm(range(Ns), "Sample: ")
224
+ for idx in pbar:
224
225
 
225
226
  # Perform one step of the sampler
226
227
  acc = self.step()
@@ -229,6 +230,9 @@ class Sampler(ABC):
229
230
  self._acc.append(acc)
230
231
  self._samples.append(self.current_point)
231
232
 
233
+ # display acc rate at progress bar
234
+ pbar.set_postfix_str(f"acc rate: {np.mean(self._acc[-1-idx:]):.2%}")
235
+
232
236
  # Add sample to batch
233
237
  if batch_size > 0:
234
238
  batch_handler.add_sample(self.current_point)
@@ -260,7 +264,8 @@ class Sampler(ABC):
260
264
  if hasattr(self, "_pre_warmup"): self._pre_warmup()
261
265
 
262
266
  # Draw warmup samples with tuning
263
- for idx in tqdm(range(Nb), "Warmup: "):
267
+ pbar = tqdm(range(Nb), "Warmup: ")
268
+ for idx in pbar:
264
269
 
265
270
  # Perform one step of the sampler
266
271
  acc = self.step()
@@ -273,6 +278,9 @@ class Sampler(ABC):
273
278
  self._acc.append(acc)
274
279
  self._samples.append(self.current_point)
275
280
 
281
+ # display acc rate at progress bar
282
+ pbar.set_postfix_str(f"acc rate: {np.mean(self._acc[-1-idx:]):.2%}")
283
+
276
284
  # Call callback function if specified
277
285
  self._call_callback(self.current_point, len(self._samples)-1)
278
286