Skip to content

Commit 4ddce21

Browse files
neuralsorcererfacebook-github-bot
authored andcommitted
patch: minor fix in q value networks (#120)
Summary: Change: - The `CNNQValueMultiHeadNetwork.get_q_values` method now checks `len(action_batch.shape)` when deciding whether to squeeze the returned tensor instead of using `len(action_batch)`. Why? - The previous logic misinterpreted a 3‑D action tensor: `len(action_batch)` returned the batch size rather than the number of dimensions, causing incorrect squeezing behavior and potentially wrong output shapes. Pull Request resolved: #120 Reviewed By: Yonathae Differential Revision: D78899714 Pulled By: rodrigodesalvobraz fbshipit-source-id: f48612c3beb4124681418992bfa02d355d95cfc8
1 parent 1265290 commit 4ddce21

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pearl/neural_networks/sequential_decision_making/q_value_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def get_q_values(
912912
q_values, # (batch_size x num actions x 1)
913913
) # (batch_size x number_of_actions_to_query x 1)
914914
q_values = q_values.squeeze(-1) # (batch_size x number_of_actions_to_query)
915-
return q_values if len(action_batch) == 3 else q_values.squeeze(-1)
915+
return q_values if len(action_batch.shape) == 3 else q_values.squeeze(-1)
916916

917917
@property
918918
def state_dim(self) -> int:

0 commit comments

Comments
 (0)