-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug Fix] Serialization of vectorActionSpace (#5220)
* [Bug Fix] Serialization of vectorActionSpace * adding a test
- Loading branch information
1 parent
357e9d6
commit 8f14b25
Showing
6 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
com.unity.ml-agents/Tests/Editor/Serialization/TestLoadOldPrefab.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
using UnityEditor; | ||
using Unity.MLAgents.Policies; | ||
|
||
namespace Unity.MLAgents.Tests | ||
{ | ||
[TestFixture] | ||
public class TestSerialization | ||
{ | ||
const string k_oldPrefabPath = "Packages/com.unity.ml-agents/Tests/Editor/TestModels/old_serialized_agent.prefab"; | ||
const int k_numVecObs = 212; | ||
const int k_numContinuousActions = 39; | ||
|
||
[Test] | ||
public void TestDeserialization() | ||
{ | ||
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(k_oldPrefabPath); | ||
var agent = GameObject.Instantiate(prefab); | ||
var bp = agent.GetComponent<BehaviorParameters>(); | ||
Assert.AreEqual(bp.BrainParameters.ActionSpec.NumContinuousActions, k_numContinuousActions); | ||
Assert.AreEqual(bp.BrainParameters.VectorObservationSize, k_numVecObs); | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
com.unity.ml-agents/Tests/Editor/Serialization/TestLoadOldPrefab.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
com.unity.ml-agents/Tests/Editor/TestModels/old_serialized_agent.prefab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &5381908961062339374 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 5379309137663827240} | ||
- component: {fileID: 5414230854946179998} | ||
- component: {fileID: 8153975132613398210} | ||
m_Layer: 0 | ||
m_Name: old_serialized_agent | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &5379309137663827240 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 5381908961062339374} | ||
m_LocalRotation: {x: -0, y: -0, z: 0, w: 1} | ||
m_LocalPosition: {x: 0, y: 0, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} | ||
--- !u!114 &5414230854946179998 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 5381908961062339374} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 5d1c4e0b1822b495aa52bc52839ecb30, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
m_BrainParameters: | ||
vectorObservationSize: 212 | ||
numStackedVectorObservations: 1 | ||
vectorActionSize: 27000000 | ||
vectorActionDescriptions: [] | ||
vectorActionSpaceType: 1 | ||
m_Model: {fileID: 11400000, guid: 4e86a19e012da43bfa5ab97ae8089b98, type: 3} | ||
m_InferenceDevice: 0 | ||
m_BehaviorType: 0 | ||
m_BehaviorName: Walker | ||
TeamId: 0 | ||
m_UseChildSensors: 1 | ||
m_UseChildActuators: 1 | ||
m_ObservableAttributeHandling: 0 | ||
--- !u!114 &8153975132613398210 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 5381908961062339374} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 88b6042bc9a5d4aa58d931eae49442e5, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
agentParameters: | ||
maxStep: 0 | ||
hasUpgradedFromAgentParameters: 1 | ||
MaxStep: 0 |
7 changes: 7 additions & 0 deletions
7
com.unity.ml-agents/Tests/Editor/TestModels/old_serialized_agent.prefab.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.