Skip to content

Commit

Permalink
Backports for v0.10.8 (#2400)
Browse files Browse the repository at this point in the history
* Fix numerical bug in `BinnedUniforms` (#2344)

prob.cumsum() - prob is a numerically unsafe way to shift prob.cumsum() to the right. The numerical error will create small gaps or overlaps in the bins defined by lower and upper bounds. If a quantile falls in one of these overlap or gap the one hot bin indicator will have 0 or 2 hot bins and generate a shape mismatch error. The fix consists of doing a shift by copy.

* Fix dominick dataset bug. (#2364)

* Proposed fix to zero seed bug. (#2379)

Co-authored-by: Sigrid Passano Hellan <[email protected]>

Co-authored-by: Marc van Oudheusden <[email protected]>
Co-authored-by: Bhaskar Dhariyal <[email protected]>
Co-authored-by: Sigrid Passano Hellan <[email protected]>
Co-authored-by: Sigrid Passano Hellan <[email protected]>
  • Loading branch information
5 people authored Oct 28, 2022
1 parent 0ef14a0 commit be1a39e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/gluonts/dataset/repository/_tsf_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def default_prediction_length_from_frequency(freq: str) -> int:
"T": 60,
"H": 48,
"D": 30,
"W": 8,
"W-SUN": 8,
"M": 12,
"Y": 4,
}
Expand Down
4 changes: 2 additions & 2 deletions src/gluonts/model/seq2seq/_mq_dnn_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class MQCNNEstimator(ForkingSeq2SeqEstimator):
It makes sense to disable this, if you don't have ``feat_dynamic_real``
for the prediction range.
seed
Will set the specified int seed for numpy anc MXNet if specified.
Will set the specified int seed for numpy and MXNet if specified.
(default: None)
decoder_mlp_dim_seq
The dimensionalities of the Multi Layer Perceptron layers of the
Expand Down Expand Up @@ -216,7 +216,7 @@ def __init__(
f"{len(self.dilation_seq)} vs. {len(self.kernel_size_seq)}"
)

if seed:
if seed is not None:
np.random.seed(seed)
mx.random.seed(seed, trainer.ctx)

Expand Down
3 changes: 2 additions & 1 deletion src/gluonts/torch/distributions/binned_uniforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def _icdf_binned(self, quantiles):
# including the bin (upper)
incomplete_cdf_upper = bins_prob.cumsum(dim=-1)
# incomplete_cdf_upper.shape: (*batch_shape, numb_bins)
incomplete_cdf_lower = bins_prob.cumsum(dim=-1) - bins_prob
incomplete_cdf_lower = torch.zeros_like(incomplete_cdf_upper)
incomplete_cdf_lower[..., 1:] = incomplete_cdf_upper[..., :-1]
# incomplete_cdf_lower.shape: (*batch_shape, numb_bins)

one_hot_bin_indicator = (incomplete_cdf_lower <= quantiles) * (
Expand Down

0 comments on commit be1a39e

Please sign in to comment.