Skip to content

Commit 5165e88

Browse files
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
1 parent 59e6dd2 commit 5165e88

File tree

6 files changed

+110
-92
lines changed

6 files changed

+110
-92
lines changed

docs/Installation.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ If you'd like to use Docker for ML-Agents, please follow
5858

5959
## Unity Packages
6060

61-
You can download ML-Agents as Unity Packages:
62-
63-
* [ML-Agents with TensorflowSharp Plugin](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsWithPlugin.unitypackage)
64-
* [ML-Agents without TensorflowSharp Plugin](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsNoPlugin.unitypackage)
65-
* [TensorflowSharp Plugin Only](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage)
61+
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).
6662

6763
## Help
6864

docs/localized/zh-CN/docs/Installation.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ Unity Assets。`python` 目录包含训练代码。
5656

5757
## Unity 包
5858

59-
您可以通过 Unity 包的形式下载 ML-Agents:
60-
61-
* 带 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)
62-
* 不带 TensorflowSharp 插件的 ML-Agents([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/ML-AgentsNoPlugin.unitypackage)[百度盘链接](https://pan.baidu.com/s/1K8fZFslW6PWNgmWA6oO4Yg)
63-
* 仅包含 TensorflowSharp 插件([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage)[百度盘链接](https://pan.baidu.com/s/1s0mJN8lvuxTcYbs2kL2FqA)
59+
您可以通过 Unity 包的形式下载TensorflowSharp 插件([AWS S3链接](https://s3.amazonaws.com/unity-ml-agents/0.3/TFSharpPlugin.unitypackage)[百度盘链接](https://pan.baidu.com/s/1s0mJN8lvuxTcYbs2kL2FqA)
6460

6561
## 帮助
6662

unity-environment/Assets/ML-Agents/Examples/Basic/Scene.unity

Lines changed: 67 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ OcclusionCullingSettings:
1313
--- !u!104 &2
1414
RenderSettings:
1515
m_ObjectHideFlags: 0
16-
serializedVersion: 9
16+
serializedVersion: 8
1717
m_Fog: 0
1818
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
1919
m_FogMode: 3
@@ -39,7 +39,6 @@ RenderSettings:
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
4141
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
42-
m_UseRadianceAmbientProbe: 0
4342
--- !u!157 &3
4443
LightmapSettings:
4544
m_ObjectHideFlags: 0
@@ -55,10 +54,11 @@ LightmapSettings:
5554
m_EnableBakedLightmaps: 1
5655
m_EnableRealtimeLightmaps: 1
5756
m_LightmapEditorSettings:
58-
serializedVersion: 10
57+
serializedVersion: 9
5958
m_Resolution: 2
6059
m_BakeResolution: 40
61-
m_AtlasSize: 1024
60+
m_TextureWidth: 1024
61+
m_TextureHeight: 1024
6262
m_AO: 0
6363
m_AOMaxDistance: 1
6464
m_CompAOExponent: 1
@@ -88,7 +88,6 @@ LightmapSettings:
8888
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
8989
m_PVRFilteringAtrousPositionSigmaIndirect: 2
9090
m_PVRFilteringAtrousPositionSigmaAO: 1
91-
m_ShowResolutionOverlay: 1
9291
m_LightingDataAsset: {fileID: 0}
9392
m_UseShadowmask: 1
9493
--- !u!196 &4
@@ -113,19 +112,6 @@ NavMeshSettings:
113112
debug:
114113
m_Flags: 0
115114
m_NavMeshData: {fileID: 0}
116-
--- !u!114 &37048259
117-
MonoBehaviour:
118-
m_ObjectHideFlags: 0
119-
m_PrefabParentObject: {fileID: 0}
120-
m_PrefabInternal: {fileID: 0}
121-
m_GameObject: {fileID: 0}
122-
m_Enabled: 1
123-
m_EditorHideFlags: 0
124-
m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3}
125-
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
126-
m_EditorClassIdentifier:
127-
broadcast: 1
128-
brain: {fileID: 0}
129115
--- !u!1 &282272644
130116
GameObject:
131117
m_ObjectHideFlags: 0
@@ -158,7 +144,6 @@ MeshRenderer:
158144
m_MotionVectors: 1
159145
m_LightProbeUsage: 1
160146
m_ReflectionProbeUsage: 1
161-
m_RenderingLayerMask: 4294967295
162147
m_Materials:
163148
- {fileID: 2100000, guid: 260483cdfc6b14e26823a02f23bd8baa, type: 2}
164149
m_StaticBatchInfo:
@@ -355,11 +340,34 @@ MonoBehaviour:
355340
vectorObservationSpaceType: 0
356341
brainType: 0
357342
CoreBrains:
358-
- {fileID: 1986421907}
359-
- {fileID: 37048259}
360-
- {fileID: 2070181396}
361-
- {fileID: 1399890765}
362-
instanceID: 78800
343+
- {fileID: 1458832067}
344+
- {fileID: 1183791066}
345+
- {fileID: 1066285776}
346+
- {fileID: 977008778}
347+
instanceID: 21298
348+
--- !u!114 &977008778
349+
MonoBehaviour:
350+
m_ObjectHideFlags: 0
351+
m_PrefabParentObject: {fileID: 0}
352+
m_PrefabInternal: {fileID: 0}
353+
m_GameObject: {fileID: 0}
354+
m_Enabled: 1
355+
m_EditorHideFlags: 0
356+
m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3}
357+
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
358+
m_EditorClassIdentifier:
359+
broadcast: 1
360+
graphModel: {fileID: 4900000, guid: 8786b6500d406497c959f24c2a8b59ac, type: 3}
361+
graphScope:
362+
graphPlaceholders: []
363+
BatchSizePlaceholderName: batch_size
364+
VectorObservationPlacholderName: vector_observation
365+
RecurrentInPlaceholderName: recurrent_in
366+
RecurrentOutPlaceholderName: recurrent_out
367+
VisualObservationPlaceholderName: []
368+
ActionPlaceholderName: action
369+
PreviousActionPlaceholderName: prev_action
370+
brain: {fileID: 846768605}
363371
--- !u!1 &984725368
364372
GameObject:
365373
m_ObjectHideFlags: 0
@@ -391,7 +399,6 @@ MeshRenderer:
391399
m_MotionVectors: 1
392400
m_LightProbeUsage: 1
393401
m_ReflectionProbeUsage: 1
394-
m_RenderingLayerMask: 4294967295
395402
m_Materials:
396403
- {fileID: 2100000, guid: 624b24bbec31f44babfb57ef2dfbc537, type: 2}
397404
m_StaticBatchInfo:
@@ -445,6 +452,18 @@ Transform:
445452
m_Father: {fileID: 0}
446453
m_RootOrder: 4
447454
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
455+
--- !u!114 &1066285776
456+
MonoBehaviour:
457+
m_ObjectHideFlags: 0
458+
m_PrefabParentObject: {fileID: 0}
459+
m_PrefabInternal: {fileID: 0}
460+
m_GameObject: {fileID: 0}
461+
m_Enabled: 1
462+
m_EditorHideFlags: 0
463+
m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3}
464+
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
465+
m_EditorClassIdentifier:
466+
brain: {fileID: 846768605}
448467
--- !u!1 &1178588871
449468
GameObject:
450469
m_ObjectHideFlags: 0
@@ -476,7 +495,6 @@ MeshRenderer:
476495
m_MotionVectors: 1
477496
m_LightProbeUsage: 1
478497
m_ReflectionProbeUsage: 1
479-
m_RenderingLayerMask: 4294967295
480498
m_Materials:
481499
- {fileID: 2100000, guid: 624b24bbec31f44babfb57ef2dfbc537, type: 2}
482500
m_StaticBatchInfo:
@@ -530,28 +548,38 @@ Transform:
530548
m_Father: {fileID: 0}
531549
m_RootOrder: 5
532550
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
533-
--- !u!114 &1399890765
551+
--- !u!114 &1183791066
534552
MonoBehaviour:
535553
m_ObjectHideFlags: 0
536554
m_PrefabParentObject: {fileID: 0}
537555
m_PrefabInternal: {fileID: 0}
538556
m_GameObject: {fileID: 0}
539557
m_Enabled: 1
540558
m_EditorHideFlags: 0
541-
m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3}
542-
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
559+
m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3}
560+
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
543561
m_EditorClassIdentifier:
544562
broadcast: 1
545-
graphModel: {fileID: 4900000, guid: 07e40c2d0871b4e989b41d1b8519fb93, type: 3}
546-
graphScope:
547-
graphPlaceholders: []
548-
BatchSizePlaceholderName: batch_size
549-
VectorObservationPlacholderName: vector_observation
550-
RecurrentInPlaceholderName: recurrent_in
551-
RecurrentOutPlaceholderName: recurrent_out
552-
VisualObservationPlaceholderName: []
553-
ActionPlaceholderName: action
554-
PreviousActionPlaceholderName: prev_action
563+
brain: {fileID: 0}
564+
--- !u!114 &1458832067
565+
MonoBehaviour:
566+
m_ObjectHideFlags: 0
567+
m_PrefabParentObject: {fileID: 0}
568+
m_PrefabInternal: {fileID: 0}
569+
m_GameObject: {fileID: 0}
570+
m_Enabled: 1
571+
m_EditorHideFlags: 0
572+
m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3}
573+
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
574+
m_EditorClassIdentifier:
575+
broadcast: 1
576+
continuousPlayerActions: []
577+
discretePlayerActions:
578+
- key: 97
579+
value: 0
580+
- key: 100
581+
value: 1
582+
defaultAction: -1
555583
brain: {fileID: 846768605}
556584
--- !u!1 &1574236047
557585
GameObject:
@@ -698,35 +726,3 @@ Transform:
698726
m_Father: {fileID: 0}
699727
m_RootOrder: 0
700728
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
701-
--- !u!114 &1986421907
702-
MonoBehaviour:
703-
m_ObjectHideFlags: 0
704-
m_PrefabParentObject: {fileID: 0}
705-
m_PrefabInternal: {fileID: 0}
706-
m_GameObject: {fileID: 0}
707-
m_Enabled: 1
708-
m_EditorHideFlags: 0
709-
m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3}
710-
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
711-
m_EditorClassIdentifier:
712-
broadcast: 1
713-
continuousPlayerActions: []
714-
discretePlayerActions:
715-
- key: 97
716-
value: 0
717-
- key: 100
718-
value: 1
719-
defaultAction: -1
720-
brain: {fileID: 846768605}
721-
--- !u!114 &2070181396
722-
MonoBehaviour:
723-
m_ObjectHideFlags: 0
724-
m_PrefabParentObject: {fileID: 0}
725-
m_PrefabInternal: {fileID: 0}
726-
m_GameObject: {fileID: 0}
727-
m_Enabled: 1
728-
m_EditorHideFlags: 0
729-
m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3}
730-
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
731-
m_EditorClassIdentifier:
732-
brain: {fileID: 846768605}
Binary file not shown.

unity-environment/Assets/ML-Agents/Examples/Basic/TFModels/Basic.bytes.meta

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void DecideAction(Dictionary<Agent, AgentInfo> agentInfo)
190190
foreach (Agent agent in agentList)
191191
{
192192
List<float> state_list = agentInfo[agent].stackedVectorObservation;
193-
for (int j = 0; j < brain.brainParameters.vectorObservationSize * brain.brainParameters.numStackedVectorObservations; j++)
193+
for (int j = 0; j < stateLength * brain.brainParameters.numStackedVectorObservations; j++)
194194
{
195195
inputState[i, j] = state_list[j];
196196
}
@@ -501,15 +501,36 @@ public void OnInspector()
501501
#endif
502502
}
503503

504-
/// Contains logic to convert the agent's cameras into observation list
505-
/// (as list of float arrays)
506-
public static float[,,,] BatchVisualObservations(List<Texture2D> textures, bool BlackAndWhite)
504+
/// <summary>
505+
/// Converts a list of Texture2D into a Tensor.
506+
/// </summary>
507+
/// <returns>
508+
/// A 4 dimensional float Tensor of dimension
509+
/// [batch_size, height, width, channel].
510+
/// Where batch_size is the number of input textures,
511+
/// height corresponds to the height of the texture,
512+
/// width corresponds to the width of the texture,
513+
/// channel corresponds to the number of channels extracted from the
514+
/// input textures (based on the input blackAndWhite flag
515+
/// (3 if the flag is false, 1 otherwise).
516+
/// The values of the Tensor are between 0 and 1.
517+
/// </returns>
518+
/// <param name="textures">
519+
/// The list of textures to be put into the tensor.
520+
/// Note that the textures must have same width and height.
521+
/// </param>
522+
/// <param name="blackAndWhite">
523+
/// If set to <c>true</c> the textures
524+
/// will be converted to grayscale before being stored in the tensor.
525+
/// </param>
526+
public static float[,,,] BatchVisualObservations(
527+
List<Texture2D> textures, bool blackAndWhite)
507528
{
508529
int batchSize = textures.Count();
509530
int width = textures[0].width;
510531
int height = textures[0].height;
511532
int pixels = 0;
512-
if (BlackAndWhite)
533+
if (blackAndWhite)
513534
pixels = 1;
514535
else
515536
pixels = 3;
@@ -523,15 +544,22 @@ public void OnInspector()
523544
for (int h = 0; h < height; h++)
524545
{
525546
Color32 currentPixel = cc[h * width + w];
526-
if (!BlackAndWhite)
547+
if (!blackAndWhite)
527548
{
528-
result[b, textures[b].height - h - 1, w, 0] = currentPixel.r;
529-
result[b, textures[b].height - h - 1, w, 1] = currentPixel.g;
530-
result[b, textures[b].height - h - 1, w, 2] = currentPixel.b;
549+
// For Color32, the r, g and b values are between
550+
// 0 and 255.
551+
result[b, textures[b].height - h - 1, w, 0] =
552+
currentPixel.r / 255.0f;
553+
result[b, textures[b].height - h - 1, w, 1] =
554+
currentPixel.g / 255.0f;
555+
result[b, textures[b].height - h - 1, w, 2] =
556+
currentPixel.b / 255.0f;
531557
}
532558
else
533559
{
534-
result[b, textures[b].height - h - 1, w, 0] = (currentPixel.r + currentPixel.g + currentPixel.b) / 3;
560+
result[b, textures[b].height - h - 1, w, 0] =
561+
(currentPixel.r + currentPixel.g + currentPixel.b)
562+
/ 3;
535563
}
536564
}
537565
}

0 commit comments

Comments
 (0)