Giter Site home page Giter Site logo

deepar's People

Contributors

arrigonialberto86 avatar benman1 avatar ketan-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deepar's Issues

Prediction on testing set

great implementation, easy to understand. yet the prediction is made on the training set. I need to predict on testing set, making the decoder part, where the output from one cell is the input to the next one.

Hello, I have some questions about the loss function of the Gaussian distribution

The loss function of the Gaussian distribution given in the code is as follows:

tf.reduce_mean(0.5*tf.math.log(sigma) + 0.5*tf.math.truediv(tf.math.square(y_true - y_pred), sigma)) + 1e-6 + 6  

I think it can be expressed as the following mathematical formula:
\frac{{\rm{1}}}{N} \times \sum {(\frac{1}{2} \times \log (\sigma ) + \frac{1}{2} \times \frac{{{{(z - \mu )}^2}}}{\sigma })}  + 1 \times {10^{ - 6}} + 6
But according to the formula in the original text(DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks), I derived the following result:
 - 1 \times \frac{{\rm{1}}}{N} \times \sum {(\log (\frac{1}{{\sqrt {2\pi } \sigma }}{e^{ - \frac{{{{(z - \mu )}^2}}}{{2{\sigma ^2}}}}}))}
 = \frac{{\rm{1}}}{N} \times \sum {(\log (\sqrt {2\pi } \sigma ) + \frac{{{{(z - \mu )}^2}}}{{2{\sigma ^2}}})}
 = \frac{{\rm{1}}}{N} \times \sum {(\log (\sqrt {2\pi } \sigma ) + \frac{{{{(z - \mu )}^2}}}{{2{\sigma ^2}}})}
 = \frac{{\rm{1}}}{N} \times \sum {(\log (\sqrt {2\pi } ) + \log (\sigma ) + \frac{{{{(z - \mu )}^2}}}{{2{\sigma ^2}}})}
I don't know where I got it wrong and I cannot get the loss function form given in the code.

Question about loss function

I'm thinking of why it is tf.math.square(y_true - y_pred), 2 * tf.math.square(sigma) in the loss function, rather than tf.math.square(y_true - mu), 2 * tf.math.square(sigma), where mu is predicted by the model.

Question: multivariate time series

I've got this question: the code assumes different parameters in the final dense layer to produce the parameters of the Gaussian distribution in the multivariate case. But what I understand from the DeepAR paper is that the exact same network is trained with data from all time series, producing a single variable output, and what differentiates the output is an extra input with the time series index through an embedding input, am I right?

Issues with normalization and prediction

There are at least two significant issues in this implementation. Until they are fixed, don't use this repo unless you really know what you are doing. These issues are:

1-Normalization is not done properly. The current implementation applies normalization to the batch, not to the dataset.
This is problematic because:

  • Similar values are represented differently in different samples.
  • Causes data leakage, information about future values are leaked through the normalization

2-get_sample_prediction function does not do forecasting with the predicted values. The original paper uses the true values for training and the predicted values for the testing. Currently, there is no Monte Carlo sampling based forecasting function implemented in the repo.

Deepar add on features

Hello,
Am interest to discuss for addon features.
Do you have some possible contact ?

Thanks

Working with new custom timeseries example needed

Hi,

there is no example / documentation if we want to try your deepar implementation on a new custom time series.

deepar_ts = TimeSeries(pandas_df = df) does not seems to work!

Can you provide an example or documentation on how to use it ?

Thanks!

deepar main_output dimension issue

ValueErrorTraceback (most recent call last)
in ()
5 ts = TimeSeries(source_df, scaler=MinMaxScaler)
6 dp_model = DeepAR(ts, epochs=100)
----> 7 dp_model.instantiate_and_fit()

/home/appops/app/notebook/hzliuerfei/deepar/deepar/model/lstm.pyc in instantiate_and_fit(self, verbose)
50 input_shape[0]),
51 steps_per_epoch=self.steps_per_epoch,
---> 52 epochs=self.epochs)
53 if verbose:
54 logger.debug('Model was successfully trained')

/home/appops/app/anaconda2/lib/python2.7/site-packages/keras/legacy/interfaces.pyc in wrapper(*args, **kwargs)
85 warnings.warn('Update your ' + object_name + 86 ' call to the Keras 2 API: ' + signature, stacklevel=2)
---> 87 return func(*args, **kwargs)
88 wrapper._original_function = func
89 return wrapper

/home/appops/app/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
2094 outs = self.train_on_batch(x, y,
2095 sample_weight=sample_weight,
-> 2096 class_weight=class_weight)
2097
2098 if not isinstance(outs, list):

/home/appops/app/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in train_on_batch(self, x, y, sample_weight, class_weight)
1806 sample_weight=sample_weight,
1807 class_weight=class_weight,
-> 1808 check_batch_axis=True)
1809 if self.uses_learning_phase and not isinstance(K.learning_phase(), int):
1810 ins = x + y + sample_weights + [1.]

/home/appops/app/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size)
1409 output_shapes,
1410 check_batch_axis=False,
-> 1411 exception_prefix='target')
1412 sample_weights = _standardize_sample_weights(sample_weight,
1413 self._feed_output_names)

/home/appops/app/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in _standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
139 ' to have ' + str(len(shapes[i])) +
140 ' dimensions, but got array with shape ' +
--> 141 str(array.shape))
142 for j, (dim, ref_dim) in enumerate(zip(array.shape, shapes[i])):
143 if not j and not check_batch_axis:

ValueError: Error when checking target: expected main_output to have 2 dimensions, but got array with shape (1, 20, 1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.