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
WIP: examples of simple time series models #480
base: master
Are you sure you want to change the base?
Conversation
Cool! Good idea on the notebooks. I think this is the more suitable platform longer term as well. I'm looking into porting all tutorials and selected examples into notebooks. re: beta = [Normal(mu=0., sigma=2.) for i in xrange(p)] to be a vector of normals, and then apply All else looks solid. |
Do you think it's worth trying to specify the models with |
That would definitel speed up construction time although at the cost of a big drag at run time. ( its also a bit harder to specify variatiaonal approximations of random varuables inside body functions) Since you're using reparameterization gradients and/or MAP, the graph should only need to copy the likelihood once in order to swap dependence to the approximate posterior instead of the prior. You can also try diagnosing the graph from TensorBoard by specifying the logdir argument in inference. |
sounds good. i'll try monitoring with tensorboard and also digging around and doing some profiling. does edward have a reasonable way to save models and inference objects to disk? or were you just thinking pickle? thanks. |
We use the recommended approach in TensorFlow, which is to export/import If you want to save just the model parameters for either the variational approximation or probability model, you can look into |
Currently, I am also trying to use edward for time-series modeling and this PR aligns perfectly with my experiments. Thanks :). So far I only tried the
|
I also experimented with using For reference, this is how I generate the def build_ar_graph(state, epsilon):
_prev_sample, _prev_mean, x0_sample, x0_mean, x1_sample, x1_mean = state
mean = tf.gather(beta.value(), 1) * x0_sample + tf.gather(beta.value(), 0) * x1_sample
sample = mean + epsilon
return (
x0_sample, x0_mean,
x1_sample, x1_mean,
sample, mean,
)
initial = (
tf.constant(0.0), tf.constant(0.0), # < dummy sample, mean to ensure correct shape
mu + tf.random_normal([], stddev=10.0), mu,
mu + tf.random_normal([], stddev=10.0), mu,
)
epsilon = tf.random_normal([T], stddev=0.1)
x_sample, x_mean, _1, _2, _3, _4 = tf.scan(build_ar_graph, epsilon, initial)
x = Normal(
mu=x_mean,
sigma=tf.constant([10.0] * p + [0.1] * (T - p)),
value=x_sample,
) (edit: just figured out the recursion is wrong, will update it later this afternoon. Won't change the fact however, that |
Cool. Thanks for the update! re:copy. I think we'll have to make it handle dynamic ops such as scan and while_loop as special cases. |
wrt copy: at first glance, it does seem as if tf breaks down the while / scan ops into more fundamental control flow ops. I fear a more general solution is needed. |
I have written a few examples of using edward to fit some simple time series models. They are in Jupyter notebook form right now, but I'm happy to convert them to scripts if that's easier (though I think having them as notebooks with some annotations can also be useful for learning edward). Any suggestions for improvement are welcome. I am planning on adding at least two more examples, one that uses a VAR(1) model for multiple replicates of a series and another example demonstrating a VAR(p) process (p > 1).
One point to notice is that constructing the
Inference
objects takes a very long time. I haven't dug into why this is happening, but I'm guessing that there is a lot of copying going when when I connect the training data to the corresponding nodes in the computation graph. Now that ICML is over I should have some time to dig into what's actually happening during construction and ways that we could potentially speed it up.