def testMeanStep(self): prev_mean = np.asarray([[-2], [.4]], dtype=np.float32) prev_mean_tensor = self.build_tensor(prev_mean) mean_step = build_kalman_mean_step( self.get_transition_matrix_for_timestep, self.get_transition_noise_for_timestep, self.get_observation_matrix_for_timestep, self.get_observation_noise_for_timestep) new_mean, obs_mean = mean_step((prev_mean_tensor, None), t=0) self.assertAllClose(self.evaluate(new_mean), np.dot(self.transition_matrix, prev_mean) + self.bias[:, np.newaxis]) self.assertAllClose(self.evaluate(obs_mean), np.sum(self.evaluate(new_mean)) + self.observation_bias[:, np.newaxis])
def testMeanStep(self): prev_mean = np.asarray([[-2], [.4]], dtype=np.float32) prev_mean_tensor = self.build_tensor(prev_mean) mean_step = build_kalman_mean_step( self.get_transition_matrix_for_timestep, self.get_transition_noise_for_timestep, self.get_observation_matrix_for_timestep, self.get_observation_noise_for_timestep) new_mean, obs_mean = self.evaluate(mean_step((prev_mean_tensor, None), t=0)) self.assertAllClose(new_mean, np.dot(self.transition_matrix, prev_mean) + self.bias[:, np.newaxis]) self.assertAllClose(obs_mean, np.dot(self.observation_matrix, new_mean) + self.observation_bias[:, np.newaxis])