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

constraining individual weights #31

Open
Eduardinho17 opened this issue Jul 10, 2023 · 1 comment
Open

constraining individual weights #31

Eduardinho17 opened this issue Jul 10, 2023 · 1 comment

Comments

@Eduardinho17
Copy link

Hi,

I'm working on a data analysis and I'm giving 2 components to my data for NMF. Is it possible to constrain only 1 of the component's weight? Also, what we know is that in the second component, the weight should decay exponentially. Is it possible, for instance, to only fix a parameter of the exponential function?

@maffettone
Copy link
Collaborator

The first thing should be possible, but the second is not currently possible. It does sound like an interesting feature worth developing though. I'll have a think on that. One approach for now would be to initialize the second set of weights to an exponentially decaying guess, and try and nudge the optimization in that direction.

X = load_my_dataset() # torch tensor shape (m_example, n_features)
weights_1 = load_expected_weights() # torch tensor shape (m_examples, k_components)
weights_2 = load_best_guess_exponential_weights() 

model = cmf.nmf.models.NMF(X.shape,
                           2,
                           initial_weights=[weights_1, weights_2],
                           fix_weights=[True, False])
loss = model.fit(X) # Learning curve of loss over timesteps
learned_weights, learned_components = model.W.detach().numpy(), model.H.detach().numpy()

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

No branches or pull requests

2 participants