Skip to content

Add variable names to size from dims #5669

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

Closed
ricardoV94 opened this issue Mar 30, 2022 · 2 comments
Closed

Add variable names to size from dims #5669

ricardoV94 opened this issue Mar 30, 2022 · 2 comments

Comments

@ricardoV94
Copy link
Member

Would make dprint more readable

import aesara
import pymc as pm

with pm.Model(coords=dict(cities=range(5))) as m:
  x = pm.Normal("x", dims=("cities"))

aesara.dprint(x)
normal_rv{0, (0, 0), floatX, False}.1 [id A] 'x'   
 |RandomStateSharedVariable(<RandomState(MT19937) at 0x7FF40F93C540>) [id B]
 |SpecifyShape [id C] ''   
 | |MakeVector{dtype='int64'} [id D] ''   
 | | |<TensorType(int64, ())> [id E]  <- Cryptic variable!
 | |TensorConstant{(1,) of 1} [id F]
 |TensorConstant{11} [id G]
 |TensorConstant{0} [id H]
 |TensorConstant{1.0} [id I]

Instead we could give it a name (doing it manually here for illustration):

with pm.Model(coords=dict(cities=range(5))) as m:
  size = aesara.shared(len(m.coords), name="cities_dim")
  x = pm.Normal("x", size=(size,))

aesara.dprint(x)
normal_rv{0, (0, 0), floatX, False}.1 [id A] 'x'   
 |RandomStateSharedVariable(<RandomState(MT19937) at 0x7FF408D8E140>) [id B]
 |SpecifyShape [id C] ''   
 | |MakeVector{dtype='int64'} [id D] ''   
 | | |cities_dim [id E]  <- Readable variable name
 | |TensorConstant{(1,) of 1} [id F]
 |TensorConstant{11} [id G]
 |TensorConstant{0} [id H]
 |TensorConstant{1.0} [id I]
@canyon289
Copy link
Member

@flo-schu This may be a good beginner issue to work on! Let us know what you think

@flo-schu
Copy link

@flo-schu This may be a good beginner issue to work on! Let us know what you think

Thanks @canyon289. This seems doable. I'll look into it.

@ricardoV94 ricardoV94 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants