-
Notifications
You must be signed in to change notification settings - Fork 135
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
Can't find error history when option "track_errors" set to True #2
Comments
Hmm, maybe part of the problem is that I didn't use the "track_errors" option correctly. Perhaps the it should not be passed as a member of a dictionary named "options", but just as any other keyword option. So instead of running: model = mf.mf(norm_X, seed="nndsvd",rank=5, max_iter=20, initialize_only=True, objective="div", update="divergence",options={"track_error":True}) I should have run model = mf.mf(norm_X, seed="nndsvd",rank=5, max_iter=20, initialize_only=True, objective="div", update="divergence",track_error=True}) If that's how I should have done it, then maybe the documentation of mf.mf needs to be updated. Right now the part that I find confusing is:
The documentation above indicates that the "options" option is a dictionary, and that the track_error option is a member of that dictionary. Is that right? In any case, it's still not clear to me how I track the error. |
Hi Conrad, I updated the documentation and added an example of usage with error tracking to the main page of documentation. Specifically, updated docs of mf_run is here: http://helikoid.si/mf/mf.mf_run.html and example of usage is available here: http://helikoid.si/mf/#usage (under Example No. 3). For clarification, we have three types of parameters, as specified in above link. General parameters specify factorization method, rank, initialization method, etc. Runtime specific options specify error tracking, fitted factorization model tracking. You can track error (that is, objective function value from each ITERATION is stored) or fitted factorization model (that is, matrix factors from each RUN are stored, which can be space consuming, so setting callback function which is called after each run is suggested instead). You can also track error when multiple runs are performed. In that case you get the list of errors for run Please see example of usage in above links. I tested it and it works. Best, Marinka |
Thanks a lot for showing me how to track the error. Problem solved! |
I runned orl_images example with lsnmf method and track_error set to 'True' and printed errors as in example no. 3
I getted output below: Reading ORL faces database ... objective function value shouldn't be non-increasing? |
Hi leokury, First, MF documentation of LSNMF method contains explanation of algorithm specific parameters and reference to the article, which explains in detail implemented LSNMF stopping conditions and algorithm; in particular in the article (reference is at above link) see section Stopping Conditions, Equation 19, 20 and 21. Second, here is a small summary of the above and explanation. LSNMF algorithm is alternating nonnegative least squares matrix factorization using projected gradient method for each subproblem and is characterized by bound constrained optimization. As expressed by author (in above paper), in bound constrained optimization, a common condition to check if x_k (solution in k-th iteration) is close to a stationary point is checking if projected gradient norm of x_k is less or equal than initial gradient norm multiplied by an epsilon parameter. The role of the epsilon, that is tolerance for a stopping condition has in the case of LSNMF Note, that the factorization is performed until at least one stopping condition is met. In your case, met stopping condition was the maximum number of iteration (that is max_iter=10), but after each update of matrix factors projected gradient norm has been greater than initial gradient norm multiplied by tolerance, as explained in above paragraph. So, the results you printed with tracking the error, are projected gradient norms of matrix factors and these are not necessarily non-increasing, especially after performing so small number of iterations. There are numerous possible stopping conditions and some are algorithm dependent. Check the documentation and try different settings of algorithm specific parameters. Again, in some applications and with some algorithms finishing the factorization after the first iteration in which the objective value has been increased, is not necessarily the best solution, as many issues can arise in local optimization. The usage of projected gradient norm in stopping condition for LSNMF is used by the author of LSNMF method as well (reference at above link). Best, Marinka |
Whenever I perform MF, I'd like to know whether the objective has converged or whether I should have run more iterations. So I was happy to read about the "track_error" option. However, I can't figure out how to use this option.
I have looked through the examples and none of them seem to use this option. In fact, none of them seem to use the "options" parameter, which is a dictionary.
So this "issue" is really just a question: how do I actually track the residuals? It's also a bit of a suggestion to make this clear in one of your examples, or perhaps even in one of the examples on the main mf page.
Here is what I have tried:
The fit object does not seem to have a "error_tracking" attribute or function, and neither does the summary object.
Also, when I now type
it prints "False"
but when I type
it prints {'objective': 'div', 'options': {'track_error': True}, 'update': 'divergence'}
The text was updated successfully, but these errors were encountered: