Open hidesoon opened 4 years ago
Ah, good catch; the example should read
imputed_series_distribution = tfp.sts.impute_missing_values(
model,
observed_time_series,
parameter_samples=parameter_samples)
where parameter_samples
is as returned from fit_with_hmc
.
We'll have a fix pushed soon. Thanks for reporting this!
thanks @davmre to point out the solution, it should be a simple one,
I just run the example from the official website:
I have encountered one warning and one error:
TypeError Traceback (most recent call last) in 1 # Impute missing values 2 imputed_series_distribution = tfp.sts.impute_missing_values( ----> 3 model, observed_time_series) 4 print('imputed means and stddevs: ', 5 imputed_series_distribution.mean(),
TypeError: impute_missing_values() missing 1 required positional argument: 'parameter_samples'
Then I tried to fill the missing argument:
TypeError Traceback (most recent call last) in 1 # Impute missing values 2 imputed_series_distribution = tfp.sts.impute_missing_values( ----> 3 model, observed_time_series, parameter_samples=None) 4 print('imputed means and stddevs: ', 5 imputed_series_distribution.mean(),
D:\xxx\xxx\Anaconda3\envs\pdm\lib\site-packages\tensorflow_probability\python\sts\forecast.py in impute_missing_values(model, observed_time_series, parameter_samples, include_observation_noise) 449 tf.shape(input=observed_time_series))[-2] 450 lgssm = model.make_state_space_model( --> 451 num_timesteps=num_timesteps, param_vals=parameter_samples) 452 posterior_means, posterior_covs = lgssm.posterior_marginals( 453 observed_time_series, mask=mask)
D:\xxx\xxx\Anaconda3\envs\pdm\lib\site-packages\tensorflow_probability\python\sts\structural_time_series.py in make_state_space_model(self, num_timesteps, param_vals, initial_state_prior, initial_step) 156 return self._make_state_space_model( 157 num_timesteps=num_timesteps, --> 158 param_map=self._canonicalize_param_vals_as_map(param_vals), 159 initial_state_prior=initial_state_prior, 160 initial_step=initial_step)
D:\xxx\xxx\Anaconda3\envs\pdm\lib\site-packages\tensorflow_probability\python\sts\structural_time_series.py in _canonicalize_param_vals_as_map(self, param_vals) 129 param_map = param_vals 130 else: --> 131 param_map = {p.name: v for (p, v) in zip(self.parameters, param_vals)} 132 133 return param_map
TypeError: zip argument #2 must support iteration
Hope the example code from the official instruction page can be fixed.
Many thanks