From 5165e883c353ea67a5a76bbcf22e16ce4241c769 Mon Sep 17 00:00:00 2001 From: vincentpierre Date: Mon, 16 Apr 2018 13:29:08 -0700 Subject: [PATCH] Hotfix 0.3.1a (#625) * [CoreBrain] Bug fix in the internal brain Discrete vector observations did not have the right size * [Docs] Removed all references to the unitypackages other than the TensorFlowSharp.unitypackage . * [Basic] Updated the bytes file of basic * [Docs] Addressed comments * [Docs] Re-addressed the comments * [Bug Fix] Scalling the visual input between 0 and 1 * [Comments] Added comments to the BatchVisualObservations method of the CoreInternalBrain. * [Renaming] Renamed BlackAndWhite to blackAndWhite --- docs/Installation.md | 6 +- docs/localized/zh-CN/docs/Installation.md | 6 +- .../ML-Agents/Examples/Basic/Scene.unity | 138 +++++++++--------- .../Examples/Basic/TFModels/Basic.bytes | Bin 2461 -> 4075 bytes .../Examples/Basic/TFModels/Basic.bytes.meta | 4 +- .../ML-Agents/Scripts/CoreBrainInternal.cs | 48 ++++-- 6 files changed, 110 insertions(+), 92 deletions(-) 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 c20654df5679552c104a15dc7ddd63f7f37bd5b6..bc729a18c1a12f7e27ff92b52e2677ef6ee211bd 100644 GIT binary patch delta 2153 zcmZuydpMQ(7Pi@LJH)1P$+Zi)ZptP0w|-JO5{INAWs2-D3C9+Ow51dxYCB_3xuva( zC}~jgt3>|`sV9icrvbpI8 zI2U%0J~-fw?vD#G$AzJLXJmN8>IDQ;Yhyk%;A1OOGW+CBN|f>ehHNcivt$ujH#ZNz zKYazen{MK!VRhyS?W5CwRwlJb3qyT-;g0hF)xL2VNy=Erh`7~yaN@hKaJjq=yHypL z^OvXT4|SpBeX|ddPY`m`_$aJB7C_n)N>R~~%LMIsiO+dwA^6P$+!v|IEE;Tw+3|`b z_Sjt*7_nlU9%++ye1K^(O-Acq$58229iF&LNN1lVk({z4l_opDZPJERnCdWPnGZzB zydT7szHFi&--XZW5ra0lknh1yfr-;`|BfMUAdI`XO#(qJRURlW(J3xx;Fn*yik29MDr9Q>Ppry?7hj+j@&zXdGS&`5xeLILgf``FUXh?6zz+^5dT<^wIjXl99V^+-b8?({Nwg@C+nV=B11Oh9r z(_2%IV6*lCd@VFWTy+%9##LbPVhLUq8C7CZdLc$Fa)jFIB79+5j@w6zA++f+mG$zu zNBfu-&8-mPi)F1;-FOZ>8aKrLb1s-Gy+_M^*=;eVNz@-v6v*ZARR1PxjN5*fKDa#_ z<)=%r_~9_W=gc866S~s5k;$}GfDZK7b;FzVKmR~(3;Ng0QFO)o0{ZY=p+lnyt@IA# z*2A$N>$`x#KN>-rl`B>Lo?te~2kjbr_{qNo+vOu|yqCzAhlJB|cMH10<{AWge+jp; zYEkpaW)yaHVUf5CllGT^=bN)_TPr(ovZe*2I$E)3YZeqFoCls&FqO4$FNXVE7U9nC zO0e#oA0)7anC2fu%TL-+pJ%6FV@);G+O%M3b{0ystLTid<9K=M9>r2>Mz`nnIQrBB zlijna80%CR$>^pOeqY{J@^uGjM$N;lM+@3`FMi~!?OFqR0jXe>X99KbEzPsH0M5-$ zv?Y$%=6j1$kc;xJaxRu*N#QB_i<$H2K63@iem(`KkDo)cWhQ*D!Y{CFZ3g-kdO(%L zv#saodU$Ilqo)oSV~J=l3_WmxhKUPQaa}vgijLBfz_#Q-%1=P%>0Z=R>jRP#7Kc?Kmd zXRJ?9Z{Ph5?n^23v#^A~IR%g~QHd&xz6PhgG&U@7qS@!wA(1X^OIFogwi2(6iD}-9CGGajJk*eu(VqLFv88S~vcXpbqjfy| zjeQMMwzPrEi7<4kZh$S}kvMJNjMEn@P=Bo#tdh7zT}N@yzX;6gwglB#N`JWmJeWDXpL=D+jYBIuNLm1=kds zp`j*@8d4VJK<-0d>?Po*yx=Ju~A&r{{XQuTi@P=qyCBY-xbGI z`m-5+iZ2KMh~$sc|K5si*a4#Es!8}qi6V2m-;6P=wb(vSu#!Pjl1)=O06BloDW~oGp zWIk177R9{8Vei+llCYR5<4I6YG+vx!diCB8@LAWG7=fsWB}zIW9@oU`Hv$TIt|+oKQ#naX4`xEgv4w^2@O tYM?!<7w2uT0=_r7G%jO_z17k+KKiEnm#bTx!~;rvv8wu4{{{#5Z55g{lO;y*J!F{n|dhd{VDH!t6%A^gCO=l!l%?UE`5H zMK7YhlTZoDA14Y4WMyu1WiLf+brJ(bY;_t8WMyu1WiL%(bWL?^lX(hHf9;ICz5YLJ zJyV&Hz2r=bJ+c9`Jt?b_y`-$@J=98>z2n^pzH@EWJ=>Diy|0A?KK~dOK4DRJy^uuQ zy-I@0J>7?&z48^=J;kaLKETqjy+m&Ry;pXYJsi#zK6QeHy>e{Py%7Q;KI2clamg514V3glMoNv3}xK_ 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; } } }