Copilot commented on code in PR #19251:
URL: https://github.com/apache/iotdb/pull/19251#discussion_r4558840855
##########
iotdb-core/ainode/iotdb/ainode/core/util/serde.py:
##########
@@ -81,45 +80,36 @@ def convert_tensor_to_tsblock(data_tensor: torch.Tensor):
elif data_tensor.dim() == 1:
data_tensor = data_tensor.unsqueeze(0)
- # Transpose the tensor to [sequence_length, target_count]
- data_frame = pd.DataFrame(data_tensor.cpu()).T
- # sequence_length, target_count
- position_count, value_column_size = data_frame.shape[0],
data_frame.shape[1]
+ # one value column per target, each of sequence_length values
+ columns = data_tensor.detach().cpu().numpy()
+ value_column_size, position_count = columns.shape[0], columns.shape[1]
Review Comment:
Reading only the first two dimensions accepts higher-rank tensors that the
previous DataFrame conversion rejected; classification postprocessing does not
enforce tensor rank. For a `(1, 2, 3)` tensor, the header declares two
positions but the value column writes six values, producing an inconsistent
TsBlock. Unpack `columns.shape` directly into the two variables to reject these
inputs after scalar/1-D normalization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]