Skip to content
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

Remove need for .value when referring to internal param values. #111

Open
peterjliu opened this issue Oct 16, 2020 · 1 comment
Open

Remove need for .value when referring to internal param values. #111

peterjliu opened this issue Oct 16, 2020 · 1 comment
Assignees
Labels
feature request New feature or request

Comments

@peterjliu
Copy link
Contributor

peterjliu commented Oct 16, 2020

When referring to a Module's internal variables in call, one needs to use self.x.value instead of simply self.x. It'd be nice to enable this syntactic sugar to improve the readability of complex math expressions. For example, tf.module allows this

 class Dense(tf.Module):
   def __init__(self, in_features, out_features, name=None):
     super(Dense, self).__init__(name=name)
     self.w = tf.Variable(
       tf.random.normal([in_features, out_features]), name='w')
     self.b = tf.Variable(tf.zeros([out_features]), name='b')
   def __call__(self, x):
     y = tf.matmul(x, self.w) + self.b
     return tf.nn.relu(y)
@AlexeyKurakin AlexeyKurakin added the feature request New feature or request label Oct 19, 2020
@AlexeyKurakin AlexeyKurakin self-assigned this Oct 20, 2020
@AlexeyKurakin
Copy link
Member

I will implement it after JAX team will make this change: google/jax#4725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants