Skip to content
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

[WIP] [Fix] Fixing collect observation called on done #5375

Merged
merged 4 commits into from
May 20, 2021

Conversation

vincentpierre
Copy link
Contributor

@vincentpierre vincentpierre commented May 19, 2021

Proposed change(s)

@ervteng noticed that "If you put a GoalSensor/VectorSensorComponent on a dodgeball agent, and add to it in Collectobservations, it will throw a warning when the agent dies"
Investigation showed that the code

            if (collectObservationsSensor != null)
            {
                // Make sure the latest observations are being passed to training.
                collectObservationsSensor.Reset();
                using (m_CollectObservationsChecker.Start())
                {
                    CollectObservations(collectObservationsSensor);
                }
            }

is problematic when using a VectorSensor because only the collectObservationsSensor will be reset BUT both the VectorSensor and collectObservationsSensor will have new observations (because CollectObservations is called).
The proposed solution is to replace the call to collectObservationsSensor.Reset(); with UpdateSensors which is what we do in SendInfoToBrain() already. We also remove the check if (collectObservationsSensor != null) because there could be a Vector Sensor without a collectObservationsSensor.

I also modified the test of the stacking sensor to fit this new logic.

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

Slack message

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

@vincentpierre vincentpierre self-assigned this May 19, 2021
Copy link
Contributor

@dongruoping dongruoping left a comment

Choose a reason for hiding this comment

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

We should add tests to make sure the last observation is not missing nor doubled.

@vincentpierre vincentpierre merged commit 9f6b4b8 into main May 20, 2021
@delete-merged-branch delete-merged-branch bot deleted the fix-done-collect-obs branch May 20, 2021 18:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2022
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.

3 participants