Exemplo n.º 1
0
    public IEnumerator Train()
    {
        yield return(StartCoroutine(FocusTraining()));

        NeuralNetworkProperties properties = new NeuralNetworkProperties(batchSize, trainingInput, trainingAnswer, testingInput, testingAnswer, hiddenLayerSizes);

        yield return(StartCoroutine(client.deepLearningClient.DeepLearning(properties)));

        DefocusTraining();
    }
Exemplo n.º 2
0
    public IEnumerator DeepLearning(NeuralNetworkProperties properties)
    {
        string json = JsonUtility.ToJson(properties);

        Debug.Log(json);
        byte[] data = System.Text.Encoding.UTF8.GetBytes("ni" + json);
        int    bytes;
        string responseData = "";

        netStream.Write(data, 0, data.Length);

        ReportDeepLearningAccuracy();

        Debug.Log("Begin training...");
        int i = 0;

        while (true)
        {
            if (breakFlag)
            {
                breakFlag = false;
                break;
            }

            data = System.Text.Encoding.UTF8.GetBytes("nt");
            netStream.Write(data, 0, data.Length);

            data         = new byte[1024];
            bytes        = netStream.Read(data, 0, data.Length);
            responseData = System.Text.Encoding.UTF8.GetString(data, 0, bytes);
            //float loss = float.Parse(responseData);
            //Debug.Log(loss);

            if (i % 10 == 0)
            {
                ReportDeepLearningAccuracy();
            }

            i += 1;
            yield return(null);
        }
        Debug.Log("Finished");

        ReportDeepLearningAccuracy();
    }