Skip to content

Add Gradient Capability#268

Open
cjkunselman18 wants to merge 28 commits into
PhasesResearchLab:masterfrom
cjkunselman18:Gradient-based_update
Open

Add Gradient Capability#268
cjkunselman18 wants to merge 28 commits into
PhasesResearchLab:masterfrom
cjkunselman18:Gradient-based_update

Conversation

@cjkunselman18
Copy link
Copy Markdown

This pull request uses Jansson derivatives to calculate and output the gradient of each contribution to the likelihood function for use in gradient-based optimization.

else:
vertex_comp_estimate = np.squeeze(single_eqdata.X)[np.nanargmax(df),:]

counter = 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that this part will also fail if one of the phases has a phase model only in sub-component space (ex. if you're trying to assess an A-B-C system, but one of the phase models is $(B,C)_2(C)$ with no A solubility) since the Workspace creation at line 320 takes in all the components.

My quick and dirty solution was to assume that parameters in sub-component spaces were fixed, so that the driving force gradients for these sub-component phases were 0. But a better solution should allow for assessing parameters in the sub-component spaces. A possible way would be to have additional PhaseRecordFactory objects for the sub-component spaces if needed and using the corresponding PhaseRecordFactory when creating the Workspace object, but not sure if this is most efficient solution.

Also, shifting the composition to be between 5e-6 and 1-5e-6 can be done with vertex_comp_estimate[counter] = np.clip(vertex_comp_estimate[counter], 5e-6, 1-5e-6)

@bocklund
Copy link
Copy Markdown
Member

two changes I want to make and I think it's about ready to merge:

  1. we copy of the Database objects in context creation to prevent mutating the variables in the global state to prevent weird behavior or race conditions with the lasting Database object
  2. for performance, since gradients are a performance regression in function call time, i'd like to make the gradients behavior opt-in so that gradients are only computed if requested by the calling optimizer. this also has the benefit of allowing us to keep the test changes small and not thread through a bunch of API changes to handle gradient outputs

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

Successfully merging this pull request may close these issues.

3 participants