lindermanlab / ssm

Bayesian learning and inference for state space models
MIT License
540 stars 196 forks source link

slds fit shape bug when use inputdriven transition #139

Closed sherryxia2016 closed 1 year ago

sherryxia2016 commented 2 years ago

Hi,

I tried to run the following code:

slds = ssm.SLDS(
    emissions_dim,
    n_disc_states,
    latent_dim,
    emissions="gaussian_orthog",
    transitions="inputdriven",
)

q_lem_elbos, q_lem = slds.fit(
    datas=data,
    inputs=states_z,
    method="laplace_em",
    variational_posterior="structured_meanfield",
    num_iters=100,
    alpha=0.0,
)

However, the error occurs like follows: ValueError: shapes (282,1) and (0,21) not aligned: 1 (dim 1) != 0 (dim 0)

data.shape is (282, 21) and states_z shape is (282,). Does anyone know the reason for the error? Thanks!

mjamagon commented 2 years ago

I think you need to specify the input dimensionality. For example, if your input has shape (282,1), then you should specify M=1 when initializing your model. M is set to 0 by default.

slinderman commented 1 year ago

Exactly, thanks @mjamagon!