Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: The parameter loc has invalid values #353

Closed
a1code opened this issue Mar 22, 2021 · 3 comments · Fixed by sdv-dev/DeepEcho#30
Closed

ValueError: The parameter loc has invalid values #353

a1code opened this issue Mar 22, 2021 · 3 comments · Fixed by sdv-dev/DeepEcho#30
Assignees
Labels
bug Something isn't working
Milestone

Comments

@a1code
Copy link

a1code commented Mar 22, 2021

Environment Details

Please indicate the following details about the environment in which you found the bug:

  • SDV version: 0.8.0
  • Python version: 3.7.10
  • Operating System: Google Colaboratory Notebook

Error Description

Dataframe columns :
ticker object
date datetime64[ns]
Close float64
Low float64
High float64
Open float64
Volume float64
ff_co_name object
ff_major_ind_name object
fg_factset_ind object
exchange object
dtype: object

On running model.fit on this time series data, the execution fails with the error message ValueError: The parameter loc has invalid values.

Steps to reproduce

dailytimeseries.csv.zip

  1. Extract the dailytimeseries.csv.zip file.
  2. Run the code below.
    daily_timeseries = pd.read_csv('dailytimeseries.csv')
    entity_columns = ["ticker"]
    context_columns = ["ff_co_name", "ff_major_ind_name", "fg_factset_ind", "exchange"]
    sequence_index = "date"
    model = PAR(entity_columns=entity_columns, context_columns=context_columns, sequence_index=sequence_index,)
    model.fit(daily_timeseries)
/usr/local/lib/python3.7/dist-packages/scipy/stats/_continuous_distns.py:4798: RuntimeWarning: divide by zero encountered in true_divide
  return c**2 / (c**2 - n**2)
/usr/local/lib/python3.7/dist-packages/scipy/stats/_distn_infrastructure.py:2407: RuntimeWarning: invalid value encountered in double_scalars
  Lhat = muhat - Shat*mu
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-29-c1a28f080e61> in <module>()
----> 1 model.fit(daily_timeseries)

5 frames
/usr/local/lib/python3.7/dist-packages/sdv/timeseries/base.py in fit(self, timeseries_data)
    207 
    208         LOGGER.debug('Fitting %s model to table %s', self.__class__.__name__, self._metadata.name)
--> 209         self._fit(transformed)
    210 
    211     def get_metadata(self):

/usr/local/lib/python3.7/dist-packages/sdv/timeseries/deepecho.py in _fit(self, timeseries_data)
     83 
     84         # Validate and fit
---> 85         self._model.fit_sequences(sequences, context_types, data_types)
     86 
     87     def _sample(self, context=None, sequence_length=None):

/usr/local/lib/python3.7/dist-packages/deepecho/models/par.py in fit_sequences(self, sequences, context_types, data_types)
    330 
    331             optimizer.zero_grad()
--> 332             loss = self._compute_loss(X_padded[1:, :, :], Y_padded[:-1, :, :], seq_len)
    333             loss.backward()
    334             if self.verbose:

/usr/local/lib/python3.7/dist-packages/deepecho/models/par.py in _compute_loss(self, X_padded, Y_padded, seq_len)
    368                 for i in range(batch_size):
    369                     dist = torch.distributions.normal.Normal(
--> 370                         mu[:seq_len[i], i], sigma[:seq_len[i], i])
    371                     log_likelihood += torch.sum(dist.log_prob(X_padded[-seq_len[i]:, i, mu_idx]))
    372 

/usr/local/lib/python3.7/dist-packages/torch/distributions/normal.py in __init__(self, loc, scale, validate_args)
     48         else:
     49             batch_shape = self.loc.size()
---> 50         super(Normal, self).__init__(batch_shape, validate_args=validate_args)
     51 
     52     def expand(self, batch_shape, _instance=None):

/usr/local/lib/python3.7/dist-packages/torch/distributions/distribution.py in __init__(self, batch_shape, event_shape, validate_args)
     51                     continue  # skip checking lazily-constructed args
     52                 if not constraint.check(getattr(self, param)).all():
---> 53                     raise ValueError("The parameter {} has invalid values".format(param))
     54         super(Distribution, self).__init__()
     55 

ValueError: The parameter loc has invalid values
@a1code a1code added bug Something isn't working pending review labels Mar 22, 2021
@fealho
Copy link
Member

fealho commented Mar 22, 2021

Hi @a1code. This is actually an issue with our code, thanks for catching it! I'm currently working on a fix, so this should be patched soon.

@STAR-811
Copy link

STAR-811 commented Jun 2, 2022

Hi fealho! How did you fix this ValueError? Could you show me some details? I met the same problem and want to fix my code.

@STAR-811
Copy link

STAR-811 commented Jun 2, 2022

@fealho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants