diff --git a/docs/Installation.md b/docs/Installation.md index b2d2ad4b3b..f6fb2e7c0d 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -58,11 +58,7 @@ If you'd like to use Docker for ML-Agents, please follow ## Unity Packages -You can download ML-Agents as Unity Packages: - - * [ML-Agents with TensorflowSharp Plugin](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsWithPlugin.unitypackage) - * [ML-Agents without TensorflowSharp Plugin](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsNoPlugin.unitypackage) - * [TensorflowSharp Plugin Only](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage) +You can download the [TensorFlowSharp](Background-TensorFlow.md#tensorflowsharp) plugin as a Unity package [here](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage). ## Help diff --git a/docs/localized/zh-CN/docs/Installation.md b/docs/localized/zh-CN/docs/Installation.md index 8bc6541774..a5be138700 100755 --- a/docs/localized/zh-CN/docs/Installation.md +++ b/docs/localized/zh-CN/docs/Installation.md @@ -56,11 +56,7 @@ Unity Assets。`python` 目录包含训练代码。 ## Unity 包 -您可以通过 Unity 包的形式下载 ML-Agents: - - * 带 TensorflowSharp 插件的 ML-Agents([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsWithPlugin.unitypackage),[百度盘链接](https://pan.baidu.com/s/1qkWOqb0meyTorBG-So_PfA)) - * 不带 TensorflowSharp 插件的 ML-Agents([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsNoPlugin.unitypackage),[百度盘链接](https://pan.baidu.com/s/1K8fZFslW6PWNgmWA6oO4Yg)) - * 仅包含 TensorflowSharp 插件([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage),[百度盘链接](https://pan.baidu.com/s/1s0mJN8lvuxTcYbs2kL2FqA)) +您可以通过 Unity 包的形式下载TensorflowSharp 插件([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage),[百度盘链接](https://pan.baidu.com/s/1s0mJN8lvuxTcYbs2kL2FqA)) ## 帮助 diff --git a/unity-environment/Assets/ML-Agents/Examples/Basic/Scene.unity b/unity-environment/Assets/ML-Agents/Examples/Basic/Scene.unity index eaa14df6b7..718e984d0c 100644 --- a/unity-environment/Assets/ML-Agents/Examples/Basic/Scene.unity +++ b/unity-environment/Assets/ML-Agents/Examples/Basic/Scene.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 9 + serializedVersion: 8 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -39,7 +39,6 @@ RenderSettings: m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} - m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -55,10 +54,11 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 9 m_Resolution: 2 m_BakeResolution: 40 - m_AtlasSize: 1024 + m_TextureWidth: 1024 + m_TextureHeight: 1024 m_AO: 0 m_AOMaxDistance: 1 m_CompAOExponent: 1 @@ -88,7 +88,6 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -113,19 +112,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!114 &37048259 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3} - m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) - m_EditorClassIdentifier: - broadcast: 1 - brain: {fileID: 0} --- !u!1 &282272644 GameObject: m_ObjectHideFlags: 0 @@ -158,7 +144,6 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 - m_RenderingLayerMask: 4294967295 m_Materials: - {fileID: 2100000, guid: 260483cdfc6b14e26823a02f23bd8baa, type: 2} m_StaticBatchInfo: @@ -355,11 +340,34 @@ MonoBehaviour: vectorObservationSpaceType: 0 brainType: 0 CoreBrains: - - {fileID: 1986421907} - - {fileID: 37048259} - - {fileID: 2070181396} - - {fileID: 1399890765} - instanceID: 78800 + - {fileID: 1458832067} + - {fileID: 1183791066} + - {fileID: 1066285776} + - {fileID: 977008778} + instanceID: 21298 +--- !u!114 &977008778 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3} + m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) + m_EditorClassIdentifier: + broadcast: 1 + graphModel: {fileID: 4900000, guid: 8786b6500d406497c959f24c2a8b59ac, type: 3} + graphScope: + graphPlaceholders: [] + BatchSizePlaceholderName: batch_size + VectorObservationPlacholderName: vector_observation + RecurrentInPlaceholderName: recurrent_in + RecurrentOutPlaceholderName: recurrent_out + VisualObservationPlaceholderName: [] + ActionPlaceholderName: action + PreviousActionPlaceholderName: prev_action + brain: {fileID: 846768605} --- !u!1 &984725368 GameObject: m_ObjectHideFlags: 0 @@ -391,7 +399,6 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 - m_RenderingLayerMask: 4294967295 m_Materials: - {fileID: 2100000, guid: 624b24bbec31f44babfb57ef2dfbc537, type: 2} m_StaticBatchInfo: @@ -445,6 +452,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1066285776 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3} + m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) + m_EditorClassIdentifier: + brain: {fileID: 846768605} --- !u!1 &1178588871 GameObject: m_ObjectHideFlags: 0 @@ -476,7 +495,6 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 - m_RenderingLayerMask: 4294967295 m_Materials: - {fileID: 2100000, guid: 624b24bbec31f44babfb57ef2dfbc537, type: 2} m_StaticBatchInfo: @@ -530,7 +548,7 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1399890765 +--- !u!114 &1183791066 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} @@ -538,20 +556,30 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3} - m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) + m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3} + m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) m_EditorClassIdentifier: broadcast: 1 - graphModel: {fileID: 4900000, guid: 07e40c2d0871b4e989b41d1b8519fb93, type: 3} - graphScope: - graphPlaceholders: [] - BatchSizePlaceholderName: batch_size - VectorObservationPlacholderName: vector_observation - RecurrentInPlaceholderName: recurrent_in - RecurrentOutPlaceholderName: recurrent_out - VisualObservationPlaceholderName: [] - ActionPlaceholderName: action - PreviousActionPlaceholderName: prev_action + brain: {fileID: 0} +--- !u!114 &1458832067 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3} + m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) + m_EditorClassIdentifier: + broadcast: 1 + continuousPlayerActions: [] + discretePlayerActions: + - key: 97 + value: 0 + - key: 100 + value: 1 + defaultAction: -1 brain: {fileID: 846768605} --- !u!1 &1574236047 GameObject: @@ -698,35 +726,3 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1986421907 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3} - m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) - m_EditorClassIdentifier: - broadcast: 1 - continuousPlayerActions: [] - discretePlayerActions: - - key: 97 - value: 0 - - key: 100 - value: 1 - defaultAction: -1 - brain: {fileID: 846768605} ---- !u!114 &2070181396 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3} - m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone) - m_EditorClassIdentifier: - brain: {fileID: 846768605} diff --git a/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes b/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes index c20654df56..bc729a18c1 100644 Binary files a/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes and b/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes differ diff --git a/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes.meta b/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes.meta index e70ddbded0..3ad722a6cd 100644 --- a/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes.meta +++ b/unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes.meta @@ -1,5 +1,7 @@ fileFormatVersion: 2 -guid: 07e40c2d0871b4e989b41d1b8519fb93 +guid: 8786b6500d406497c959f24c2a8b59ac +timeCreated: 1523662030 +licenseType: Free TextScriptImporter: externalObjects: {} userData: diff --git a/unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs b/unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs index 5a7a5f3523..ca1b3cb484 100644 --- a/unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs +++ b/unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs @@ -190,7 +190,7 @@ public void DecideAction(Dictionary agentInfo) foreach (Agent agent in agentList) { List state_list = agentInfo[agent].stackedVectorObservation; - for (int j = 0; j < brain.brainParameters.vectorObservationSize * brain.brainParameters.numStackedVectorObservations; j++) + for (int j = 0; j < stateLength * brain.brainParameters.numStackedVectorObservations; j++) { inputState[i, j] = state_list[j]; } @@ -501,15 +501,36 @@ public void OnInspector() #endif } - /// Contains logic to convert the agent's cameras into observation list - /// (as list of float arrays) - public static float[,,,] BatchVisualObservations(List textures, bool BlackAndWhite) + /// + /// Converts a list of Texture2D into a Tensor. + /// + /// + /// A 4 dimensional float Tensor of dimension + /// [batch_size, height, width, channel]. + /// Where batch_size is the number of input textures, + /// height corresponds to the height of the texture, + /// width corresponds to the width of the texture, + /// channel corresponds to the number of channels extracted from the + /// input textures (based on the input blackAndWhite flag + /// (3 if the flag is false, 1 otherwise). + /// The values of the Tensor are between 0 and 1. + /// + /// + /// The list of textures to be put into the tensor. + /// Note that the textures must have same width and height. + /// + /// + /// If set to true the textures + /// will be converted to grayscale before being stored in the tensor. + /// + public static float[,,,] BatchVisualObservations( + List textures, bool blackAndWhite) { int batchSize = textures.Count(); int width = textures[0].width; int height = textures[0].height; int pixels = 0; - if (BlackAndWhite) + if (blackAndWhite) pixels = 1; else pixels = 3; @@ -523,15 +544,22 @@ public void OnInspector() for (int h = 0; h < height; h++) { Color32 currentPixel = cc[h * width + w]; - if (!BlackAndWhite) + if (!blackAndWhite) { - result[b, textures[b].height - h - 1, w, 0] = currentPixel.r; - result[b, textures[b].height - h - 1, w, 1] = currentPixel.g; - result[b, textures[b].height - h - 1, w, 2] = currentPixel.b; + // For Color32, the r, g and b values are between + // 0 and 255. + result[b, textures[b].height - h - 1, w, 0] = + currentPixel.r / 255.0f; + result[b, textures[b].height - h - 1, w, 1] = + currentPixel.g / 255.0f; + result[b, textures[b].height - h - 1, w, 2] = + currentPixel.b / 255.0f; } else { - result[b, textures[b].height - h - 1, w, 0] = (currentPixel.r + currentPixel.g + currentPixel.b) / 3; + result[b, textures[b].height - h - 1, w, 0] = + (currentPixel.r + currentPixel.g + currentPixel.b) + / 3; } } }