Skip to content

Increase communicator version for concatenated PNGs. #4462

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

Merged
merged 8 commits into from
Sep 9, 2020

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Sep 8, 2020

Proposed change(s)

Increase the communicator version to 1.1.0 to reflect the fact that concatenated PNG observations are not supported on older trainers.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • Code refactor

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)

Other comments

@chriselion chriselion changed the title [DO NOT MERGE] Increase communicator version for concatenated PNGs. Increase communicator version for concatenated PNGs. Sep 9, 2020
var trainerCanHandle = Academy.Instance.TrainerCapabilities == null || Academy.Instance.TrainerCapabilities.m_ConcatenatedPngObservations;
if (!trainerCanHandle)
{
throw new UnityAgentsException("Attached trainer doesn't support multiple PNGs. Upgrade to a version with communicator API >= 1.1.0");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also just "downgrade" to uncompressed observations in this case (if we move the check earlier).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went with this instead.

@@ -289,6 +289,17 @@ public static ObservationProto GetObservationProto(this ISensor sensor, Observat
}
else
{
// Check capabilities if we need to concatenate PNGs
if (sensor.GetCompressionType() == SensorCompressionType.PNG && shape.Length >= 3 &&
shape[shape.Length - 1] > 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we assuming any shape >=3 will work? I am not sure Python will support. I would say shape.Length == 3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't handle higher dimensional tensors in training, or in barracuda. Theoretically if you had your own trainer and weren't using inference, it could work. Then again, you wouldn't use PNG compression, so I'll simplify this.

@@ -5,6 +5,7 @@ namespace Unity.MLAgents
internal class UnityRLCapabilities
{
internal bool m_BaseRLCapabilities;
internal bool m_ConcatenatedPngObservations;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that internal variables need the m_ prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure either. I can just make them public since it's an internal class.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better yes.

var trainerCanHandle = Academy.Instance.TrainerCapabilities == null || Academy.Instance.TrainerCapabilities.ConcatenatedPngObservations;
if (!trainerCanHandle)
{
Debug.LogWarning("Attached trainer doesn't support multiple PNGs. Switching to uncompressed observations.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I fear this warning will be thrown a lot throughout the simulation. Should we set the compression type to None in the sensor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I'll make sure it only fires once.

Should we set the compression type to None in the sensor?

We don't currently have an interface for setting the compression type. I didn't want to make the sensor implementations check the compatibility, since they might forget.

@chriselion chriselion merged commit c4c9b61 into master Sep 9, 2020
@delete-merged-branch delete-merged-branch bot deleted the MLA-1348-concat-PNGs-communicator-version branch September 9, 2020 23:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants