simvla_twin5 / test.py
iMihayo's picture
Add files using upload-large-folder tool
fb65b3b verified
Raw
History Blame Contribute Delete
1.98 kB
import tensorflow as tf
traj_len = 20
window_size = 1
future_action_window_size = 7
effective_traj_len = traj_len - future_action_window_size
# chunk_indices = tf.broadcast_to(tf.range(-window_size + 1, 1), [effective_traj_len, window_size]) + tf.broadcast_to(
# tf.range(effective_traj_len)[:, None], [effective_traj_len, window_size]
# )
action_chunk_indices = tf.broadcast_to(
tf.range(-window_size + 1, 1 + future_action_window_size),
[effective_traj_len, window_size + future_action_window_size],
) + tf.broadcast_to(
tf.range(effective_traj_len)[:, None],
[effective_traj_len, window_size + future_action_window_size],
)
floored_chunk_indices = tf.maximum(action_chunk_indices, 0)
goal_timestep = tf.fill([effective_traj_len], traj_len - 1)
floored_action_chunk_indices = tf.minimum(tf.maximum(action_chunk_indices, 0), goal_timestep[:, None])
print(floored_chunk_indices,goal_timestep,floored_chunk_indices,floored_action_chunk_indices)
# history_len = future_action_window_size + 1
# effective_traj_len = traj_len - future_action_window_size
# chunk_indices = tf.broadcast_to(tf.range(-window_size + 1, 1), [effective_traj_len, window_size]) + tf.broadcast_to(
# tf.range(effective_traj_len)[:, None], [effective_traj_len, window_size]
# )
# action_chunk_indices = tf.broadcast_to(
# tf.range(-window_size - history_len + 1, 1 + future_action_window_size),
# [effective_traj_len, window_size + future_action_window_size + history_len],
# ) + tf.broadcast_to(
# tf.range(effective_traj_len)[:, None],
# [effective_traj_len, window_size + future_action_window_size + history_len],
# )
# floored_chunk_indices = tf.maximum(chunk_indices, 0)
# goal_timestep = tf.fill([effective_traj_len], traj_len - 1)
# floored_action_chunk_indices = tf.minimum(tf.maximum(action_chunk_indices, 0), goal_timestep[:, None])
# print(floored_chunk_indices,goal_timestep,floored_action_chunk_indices)