Skip to content

More misc hybrid action followup #4777

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 4 commits into from
Dec 18, 2020
Merged

Conversation

chriselion
Copy link
Contributor

Proposed change(s)

  • Doc cleanup
  • Don't call legacy methods if using continuous + discrete actions - this isn't a behavior change since the old combination wasn't possible
  • Warn if calling GetAction() with continuous + discrete
  • Mark SpaceType as obsolete.

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

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

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

Other comments

@@ -89,7 +89,7 @@ public class Academy : IDisposable
/// </item>
/// <item>
/// <term>1.3.0</term>
/// <description>Support action spaces with both continuous and discrete actions.</description>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Continuing my war on space.

@@ -19,9 +19,9 @@ namespace Unity.MLAgents
internal struct AgentInfo
{
/// <summary>
/// Keeps track of the last vector action taken by the Brain.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

... and my war on "vector action"

/// </summary>
public ActionBuffers storedVectorActions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

public field in an internal struct, so this is OK to rename.

var brainParams = m_PolicyFactory.BrainParameters;
var actionSpec = brainParams.ActionSpec;
// For continuous and discrete actions together, we don't need to fall back to the legacy method
if (actionSpec.NumContinuousActions > 0 && actionSpec.NumDiscreteActions > 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.

Better to avoid any confusion here - don't call the float[] version if we're using continuous + discrete (plus avoid munging the arrays)

@@ -1038,7 +1048,7 @@ void SendInfoToBrain()
CollectObservations(collectObservationsSensor);
}
}
using (TimerStack.Instance.Scoped("CollectDiscreteActionMasks"))
using (TimerStack.Instance.Scoped("WriteActionMask"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Old name

// For continuous and discrete actions together, this shouldn't be called because we can only return one.
if (actionSpec.NumContinuousActions > 0 && actionSpec.NumDiscreteActions > 0)
{
Debug.LogWarning("Agent.GetAction() when both continuous and discrete actions are in use. Use Agent.GetStoredActionBuffers() instead.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we should throw or log here.

@@ -64,6 +64,18 @@ public void TestEnsureBufferDiscrete()
Assert.IsTrue(7 == manager.StoredActions.DiscreteActions.Length);
}

[Test]
public void TestAllowMixedActions()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A version of this (that checked for failure) was removed in the hybrid action PR. Adding it back to make sure we can do it.

@chriselion chriselion merged commit 27f7156 into release_11_branch Dec 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the hybrid-action-followup branch December 18, 2020 18:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 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