-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
shape attribute not updated when using it with a shared variable #2326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You set the shape of mu_phi = CAR2('mu_phi', mu=tt.zeros_like(X_shared)) or maybe
|
mhh ok! with the first solution I have an error (I have to specify shape) with the second one:
Is there a way to "dynamically" get the shape as int? |
Hm. This is more complicated than I thought. I think the problem is that the bijection object for converting the model variables between array and dict expects constant shapes. At first I thought this shouldn't be a problem because we are doing something similar for minibatches, but I think that only applies to observed variables. So I don't expect that to change soon. In general it seems dynamically changing shapes are difficult to deal with. |
@denadai2 I think about it a bit more as well: In principle you should have a RV that can be broadcasted to a dynamic shape for this to work. Something along the line of So in your case, can you reparameterize the model? |
@aseyboldt mhh ok. The problem is that this appears when you have to do predictions with holdout data and multivariate models like this one :( @junpenglao how could I? Any suggestion? In the "real" problem I have, CAR is a set of parameters extracted from a Z (shared) variable. Since Z changes, I have to change the CAR shape as well... |
You can have a look at the Another idea is that, below your training model, add a generation model (similar to Stan): with pm.Model():
[...]
para = CAR(**args, shape=Xtrain.shape)
likelihood = dist(**args, observed=Ytrain)
[...]
para_new = CAR(**args, shape=Xtest.shape)
y_predict = dist(**args) And then compare the y_predict with Ytest for your purpose. |
@junpenglao I tried to think about a possible solution, but CAR is a vector estimated from an adjacency matrix, so it is not easy to do a matrix multiplication (I think!) because the new parameters depend on the matrix of X_test. For the generation model, do you mean something like this?
I didn't understand the meaning so much... Thanks for your patience in advance :) |
@denadai2 Yep that's exactly what I meant ;-) |
I have a problem with the shape parameter, that doesn't get updated when I update a shared variable. This is a toy example: it doesn't make so sense by itself but it is to reproduce the error.
the problem is with shape parameter of CAR2, which stays = to 76 but it should be shape=1 after the update.
file:
data_bug.csv.zip
The text was updated successfully, but these errors were encountered: