Hello,
I am trying to work with tfp.experimental.mcmc.particle_filter
but I do not understand how the input ‘observation’ is supposed to be formatted in case my observations are tensors of shape 2. Suppose we have 5 states in the model. What I am giving as input in this case is a tensor of shape (5, 2), where each row is an observation and each column is a dimension of the state, but this is not correct as it forces me insert num_particles=2
.
Anyone able to help me figuring this out? Thank you.
Hi @Alessandro_S
Thank you for using Tensorflow
According to the documentation of particle_filter the observations should be a tensor of shape [num_timesteps, observation_dimension]
. In your case with 5 states, the correct format would be a tensor of shape (5, 2)
, where
observations = tf.constant([
[1.0, 2.0], # Timestep 1
[1.5, 2.5], # Timestep 2
[2.0, 3.0], # Timestep 3
[2.5, 3.5], # Timestep 4
[3.0, 4.0] # Timestep 5
], dtype=tf.float32)
The structure of tensor is [num_timesteps, observation_size]
rather than [num_states, observation_dims]
. This allows the particle filter to correctly handle the sequential nature of the observations.