/// Nothing to implement public void InitializeCoreBrain() { if ((brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator == null) || (!broadcast)) { coord = null; } else if (brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator is ExternalCommunicator) { coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator; coord.SubscribeBrain(brain); } }
/// Nothing to implement public void InitializeCoreBrain(Communicator communicator) { if ((communicator == null) || (!broadcast)) { coord = null; } else if (communicator is ExternalCommunicator) { coord = (ExternalCommunicator)communicator; coord.SubscribeBrain(brain); } }
/// Create the reference to decision public void InitializeCoreBrain(Communicator communicator) { decision = brain.gameObject.GetComponent <Decision>(); if ((communicator == null) || (!broadcast)) { coord = null; } else if (communicator is ExternalCommunicator) { coord = (ExternalCommunicator)communicator; coord.SubscribeBrain(brain); } }
/// Generates the communicator for the Academy if none was present and /// subscribe to ExternalCommunicator if it was present. public void InitializeCoreBrain() { if (brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator == null) { coord = null; throw new UnityAgentsException(string.Format("The brain {0} was set to" + " External mode" + " but Unity was unable to read the" + " arguments passed at launch.", brain.gameObject.name)); } else if (brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator is ExternalCommunicator) { coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator; coord.SubscribeBrain(brain); } }
/// Loads the tensorflow graph model to generate a TFGraph object public void InitializeCoreBrain() { #if ENABLE_TENSORFLOW #if UNITY_ANDROID // This needs to ba called only once and will raise an exception if // there are multiple internal brains try{ TensorFlowSharp.Android.NativeBinding.Init(); } catch { } #endif if ((brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator == null) || (!broadcast)) { coord = null; } else if (brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator is ExternalCommunicator) { coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator; coord.SubscribeBrain(brain); } if (graphModel != null) { graph = new TFGraph(); graph.Import(graphModel.bytes); session = new TFSession(graph); if (graph[graphScope + BatchSizePlaceholderName] != null) { hasBatchSize = true; } if ((graph[graphScope + RecurrentInPlaceholderName] != null) && (graph[graphScope + RecurrentOutPlaceholderName] != null)) { hasRecurrent = true; } if (graph[graphScope + StatePlacholderName] != null) { hasState = true; } } #endif }
/// Generates the communicator for the Academy if none was present and /// subscribe to ExternalCommunicator if it was present. public void InitializeCoreBrain() { if (brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator == null) { coord = new ExternalCommunicator(brain.gameObject.transform.parent.gameObject.GetComponent <Academy>()); brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator = coord; coord.SubscribeBrain(brain); } else { if (brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator is ExternalCommunicator) { coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent <Academy>().communicator; coord.SubscribeBrain(brain); } } }
/// Loads the tensorflow graph model to generate a TFGraph object public void InitializeCoreBrain(Communicator communicator) { #if ENABLE_TENSORFLOW #if UNITY_ANDROID // This needs to ba called only once and will raise an exception if // there are multiple internal brains try{ TensorFlowSharp.Android.NativeBinding.Init(); } catch { } #endif if ((communicator == null) || (!broadcast)) { coord = null; } else if (communicator is ExternalCommunicator) { coord = (ExternalCommunicator)communicator; coord.SubscribeBrain(brain); } if (graphModel != null) { graph = new TFGraph(); graph.Import(graphModel.bytes); session = new TFSession(graph); // TODO: Make this a loop over a dynamic set of graph inputs if ((graphScope.Length > 1) && (graphScope[graphScope.Length - 1] != '/')) { graphScope = graphScope + '/'; } if (graph[graphScope + BatchSizePlaceholderName] != null) { hasBatchSize = true; } if ((graph[graphScope + RecurrentInPlaceholderName] != null) && (graph[graphScope + RecurrentOutPlaceholderName] != null)) { hasRecurrent = true; var runner = session.GetRunner(); runner.Fetch(graph[graphScope + "memory_size"][0]); var networkOutput = runner.Run()[0].GetValue(); memorySize = (int)networkOutput; } if (graph[graphScope + VectorObservationPlacholderName] != null) { hasState = true; } if (graph[graphScope + PreviousActionPlaceholderName] != null) { hasPrevAction = true; } } observationMatrixList = new List <float[, , , ]>(); texturesHolder = new List <Texture2D>(); #endif }