arrigonialberto86 / deepar Goto Github PK
View Code? Open in Web Editor NEWTensorflow implementation of Amazon DeepAR
License: MIT License
Tensorflow implementation of Amazon DeepAR
License: MIT License
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?
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:
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.
The class for generating TimeSeries data fails when using DeepAR because it lacks the 'dimension' attribute.
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!
What is the gamma function you have used to implement NBL likelihood ?
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,
Am interest to discuss for addon features.
Do you have some possible contact ?
Thanks
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)
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.
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:
But according to the formula in the original text(DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks), I derived the following result:
I don't know where I got it wrong and I cannot get the loss function form given in the code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.