You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering a shape mismatch error when trying to use the OpenLSTML4casadi model within the RealTimeL4CasADi wrapper. The error occurs when calling the forward method of the LSTM, which is part of the OpenLSTML4casadi class. Despite reshaping inputs and initializing the hidden/cell states according to the LSTM's requirements, the error persists.
Error Traceback:
RuntimeError: output with shape [1, 512] doesn't match the broadcast shape [1, 1, 512]
I ensured that the input tensor (u_train) is reshaped to [sequence_length, batch_size, input_size] before being passed to the LSTM.
I initialized the hidden and cell states (hn and cn) with the correct shape: [num_layers, batch_size, hidden_size] for cn and [num_layers, batch_size, proj_size] for hn.
Despite this, the error persists when calling the LSTM's forward pass.
Possible Cause:
The issue may be related to how the LSTM is handling projected outputs (proj_size=1) and internal reshaping of tensors during the batched Jacobian calculation. The shape mismatch suggests that the LSTM is returning an output tensor with an unexpected shape, which doesn't match the expected broadcasting dimensions.
Expected Behavior:
The LSTM forward pass should work without shape mismatches, and the batched Jacobian should correctly handle the model's projected output when using RealTimeL4CasADi.
I’d appreciate any insights or suggestions on how to resolve this shape mismatch issue during the LSTM forward pass or how to modify the batched Jacobian calculation to account for projected LSTM outputs.
Thank you!
The text was updated successfully, but these errors were encountered:
I'm encountering a shape mismatch error when trying to use the
OpenLSTML4casadi
model within theRealTimeL4CasADi
wrapper. The error occurs when calling theforward
method of the LSTM, which is part of theOpenLSTML4casadi
class. Despite reshaping inputs and initializing the hidden/cell states according to the LSTM's requirements, the error persists.Error Traceback:
RuntimeError: output with shape [1, 512] doesn't match the broadcast shape [1, 1, 512]
Here’s the full stack trace:
Steps to Reproduce:
OpenLSTML4casadi
model with the following parameters:n_context = 1
n_inputs = 1
sequence_length = 1
batch_size = 1
RealTimeL4CasADi
for CasADi integration.get_params
method using the following input:What I’ve Tried:
u_train
) is reshaped to[sequence_length, batch_size, input_size]
before being passed to the LSTM.hn
andcn
) with the correct shape:[num_layers, batch_size, hidden_size]
forcn
and[num_layers, batch_size, proj_size]
forhn
.Possible Cause:
The issue may be related to how the LSTM is handling projected outputs (
proj_size=1
) and internal reshaping of tensors during the batched Jacobian calculation. The shape mismatch suggests that the LSTM is returning an output tensor with an unexpected shape, which doesn't match the expected broadcasting dimensions.Expected Behavior:
The LSTM forward pass should work without shape mismatches, and the batched Jacobian should correctly handle the model's projected output when using
RealTimeL4CasADi
.Environment:
3.10.12
2.0.0+cpu
3.6.6
Additional Context:
The full project code is available here: https://github.com/LOPES3000/RealtimeL4casadi_and_LSTM_NN/. This issue arises when integrating the LSTM model into the real-time CasADi wrapper for symbolic differentiation and optimization.
Request:
I’d appreciate any insights or suggestions on how to resolve this shape mismatch issue during the LSTM forward pass or how to modify the batched Jacobian calculation to account for projected LSTM outputs.
Thank you!
The text was updated successfully, but these errors were encountered: