google / gin-config

Gin provides a lightweight configuration framework for Python
Apache License 2.0
2.04k stars 120 forks source link

[Question] How to define a parameter based on a defined one #182

Open minhtriet opened 1 year ago

minhtriet commented 1 year ago

In config.gin, I cannot do something like

GAT.embed_dim = 30     # this is for init of GAT

Attention.node_ft_dim = GAT.__init__.embed_dim
# Attention.node_ft_dim = GAT.embed_dim      # this won't work too

It won't work even when I

@gin.register
@gin.configurable
class GAT(nn.Module):

Is this feature implemented?

marcospiau commented 1 year ago

@minhtriet Same here, was looking for this feature!

alexd314 commented 1 year ago

A workaround for this might be to use a MACRO

EMBED_DIM = 30

GAT.embed_dim = %EMBED_DIM
Attention.node_ft_dim = %EMBED_DIM
Bloos commented 5 months ago

is there a way to do calculations with macros like this?

EMBED_DIM = 30

GAT.embed_dim = 2*%EMBED_DIM