-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
@@ -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> |
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.
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. |
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.
... and my war on "vector action"
/// </summary> | ||
public ActionBuffers storedVectorActions; |
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.
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) |
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.
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")) |
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.
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."); |
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.
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() |
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.
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.
Proposed change(s)
Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
Types of change(s)
Checklist
Other comments