-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[versioning] Save ML-Agents version in checkpoints and check on load #4035
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
Conversation
|
||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
# This is the version number of the inputs and outputs of the model, and | ||
# determines compatibility with inference in Barracuda. | ||
API_VERSION_NUMBER = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MODEL_FORMAT_VERSION_NUMBER
? "API" doesn't really feel right here.
:param version_string: The semantic-versioned version string (X.Y.Z). | ||
:return: A Tuple containing (major_ver, minor_ver, patch_ver). | ||
""" | ||
split_ver = version_string.split(".")[0:3] # Remove dev tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use distutils.version.LooseVersion
to simplify this:
>>> from distutils.version import LooseVersion
>>> v = LooseVersion("1.2.3.dev4")
>>> v
LooseVersion ('1.2.3.dev4')
>>> v.version
[1, 2, 3, 'dev', 4]
>>> v.version[0:3]
[1, 2, 3]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that is very handy! Updated to use the LooseVersion class.
Proposed change(s)
This PR saves the semantic version of the trainer package (
major
,minor
, andpatch
) as 3 variables in the TF graph. It is also exported into the .nn file. This lets us check whether a checkpoint is being loaded from the same version of ML-Agents, and (in the future) check which version of ML-Agents created a particular NN file.Note that this is different than the existing version number in the NN, which is checked by C#. That number corresponds to the input and output tensors. It is possible, when upgrading the Trainer code, for an NN file to remain compatible with C# but not be loadable into Python for training (e.g. if the network architecture changes).
Currently, we throw a warning if the versions don't match when a user tries to load a checkpoint.
Types of change(s)
Checklist