-
Notifications
You must be signed in to change notification settings - Fork 74k
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
Multiple variable contraint #56217
Comments
@NEGU93 Could you elaborate about your feature and please specify the use cases for this feature. Thank you! |
Sure. Example 1:
Is that maybe a constraint on the norm for weights and biases separately are not enough. Maybe the bias max norm should be lower if the norm of the weigths is already big. Example 2 My use case (so, another example), is that I do a Complex-Valued layer by using real and imaginary parts separately and simulating a complex operation. I want to impose contraint on the norm of the absolute value, which is not possible if I don't know both values at the same time when computing the norm. Basically, the constraint is applied by knowing or using another variable's value. I would therefore like for the constraint to receive and change two variables at the same time. in the weight/bias example the constraint will receive both I hope this is clearer. Regards, |
Hello @NEGU93 , thanks for the request. Would you mind providing usage code snippets of the apis you're proposing so it's clearer what the request is here, for the following two options?
|
Giving it some thoughts, does it appear that you'd need both 1) the Also, assuming this gets an okay from Keras team to proceed, would you be interested in contributing? |
Wouldn't the second option easily allow for the implementation of the first one? I think about this pseudo-code:
A more generic implementation will use In any case, is more the second one that I am particuarly interested. As you noted, what I need is to be able to receive multiple variables. I am willing to explain as much as possible and even have a short video call to discuss the feature if needed. Regarding the code I would love to contribute but I make no promises as I am at the end of my PhD. I need to finish my manuscript and I will also soon start looking for a permantent job somewhere in the world. I am sorry! PS: Another example on why this feature might be useful. |
Thanks for the quick response @NEGU93 - from what you described it appears using a custom layer can achieve this. Is there a reason why you'd like an additional type of constraint than say, and subclass of Dense? |
My custom layer cannot achieve this yet. I am not sure how can I do it.
In the example, I set a constraint on the amplitude value, also a constraint on phase would be possible. It depends on what the user of my library wants. The current solution is a constraint on both variables separately but they don't have information from each other (needed to know the amplitude or phase). |
Hi. I stumbled upon this feature request after finding the stack overflow page referenced above. I am trying to fit a (one neuron) simpleRNN layer, and wanted to constrain the absolute sum of the recurrent and kernel weights to be less than 1. If my understanding is correct, this would ensure stationary (i.e. decaying) predictions/projections for a linear activation function. I can do this by including a regularization parameter, but it would be good to do this with a constraint. As far as I am aware, this is currently impossible/difficult as mentioned above since constraints work on recurrent and kernels separately. |
Hi. Are there any updates regarding this issue? The original StackOverflow post that is referenced in this issue contains a solution with a custom layer. However this is not practical for many applications like adding the constraint to an existing layer without having to recreate the whole network, or generalizing this kind of constraints to several layer types. I think that a general way of constraining both kernel and bias at the same time is useful as there are mathecatical situations where this constraints have to affect to the whole vector of weights at one neuron, that is, the weights form the kernel and its associated bias. Furthermore, having to use the custom solution that joins the kernel and bias as a single matrix supposes that when extracting the weights from the whole network will not follow standard behaviour, as now kernel and bias will be in a single matrix, while in a usual dense layer they will be separated. This makes it difficult to generalize the use of these custom layers. |
Click to expand!
Issue Type
Feature Request
Source
source
Tensorflow Version
2.4.1
Custom Code
No
OS Platform and Distribution
Linux Ubuntu
Mobile device
No response
Python version
3.8.8
Bazel version
No response
GCC/Compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current Behaviour?
Standalone code to reproduce the issue
Relevant log output
No response
The text was updated successfully, but these errors were encountered: