public IEnumerator Evaluate(CLayerType[] simpleLayers) { if (modelHandler) { modelHandler.ShowGPUs(true); } EvaluateRequest req = new EvaluateRequest { }; bool flat = false; for (int i = 0; i < simpleLayers.Length; i++) { CLayerType l = simpleLayers[i]; switch (l) { case CLayerType.Conv: if (flat) { throw new System.ArgumentException("tried to add multidimensional layer after flatten"); } req.Layers.Add(new Evaluator.Layer { Convolution = new Evaluator.ConvolutionLayer { Filters = 32 } }); break; case CLayerType.Full: case CLayerType.Dense: if (!flat) { req.Layers.Add(new Evaluator.Layer { Flatten = new Evaluator.FlattenLayer { } }); flat = true; } req.Layers.Add(new Evaluator.Layer { Dense = new Evaluator.DenseLayer { Neurons = 128 } }); break; case CLayerType.Pool: if (flat) { throw new System.ArgumentException("tried to add multidimensional layer after flatten"); } req.Layers.Add(new Evaluator.Layer { Maxpooling = new Evaluator.MaxpoolingLayer { } }); break; case CLayerType.Dropout: req.Layers.Add(new Evaluator.Layer { Dropout = new Evaluator.DropoutLayer { Dimension = 0.5f } }); break; default: throw new System.ArgumentException("unknown layer type: " + l); } } if (!flat) { //req.Layers.Add(new Evaluator.Layer { Convolution = new Evaluator.ConvolutionLayer { Filters = 32 } }); req.Layers.Add(new Evaluator.Layer { Flatten = new Evaluator.FlattenLayer { } }); } bIsCalculating = true; using (var call = client.EvaluateAsync(req)) { //StartCoroutine(UpdateProgress()); while (!call.ResponseAsync.IsCompleted) { //accuracy = call.ResponseAsync.Result.Accuracy; yield return(new WaitForSeconds(0.5f)); } bIsCalculating = false; accuracy = call.ResponseAsync.Result.Accuracy; if (manager) { manager.CompleteComputation(accuracy); } yield return(new WaitForSeconds(0.5f)); if (modelHandler) { modelHandler.Reset(); } } }
public IEnumerator Evaluate(LayerType[] simpleLayers) { EvaluateRequest req = new EvaluateRequest { }; bool flat = false; for (int i = 0; i < simpleLayers.Length; i++) { LayerType l = simpleLayers[i]; switch (l) { case LayerType.Conv: if (flat) { throw new System.ArgumentException("tried to add multidimensional layer after flatten"); } req.Layers.Add(new Evaluator.Layer { Convolution = new Evaluator.ConvolutionLayer { Filters = 32 } }); break; case LayerType.Full: case LayerType.Dense: if (!flat) { req.Layers.Add(new Evaluator.Layer { Flatten = new Evaluator.FlattenLayer { } }); flat = true; } req.Layers.Add(new Evaluator.Layer { Dense = new Evaluator.DenseLayer { Neurons = 128 } }); break; case LayerType.Pool: if (flat) { throw new System.ArgumentException("tried to add multidimensional layer after flatten"); } req.Layers.Add(new Evaluator.Layer { Maxpooling = new Evaluator.MaxpoolingLayer { } }); break; case LayerType.Dropout: req.Layers.Add(new Evaluator.Layer { Dropout = new Evaluator.DropoutLayer { Dimension = 0.5f } }); break; default: throw new System.ArgumentException("unknown layer type: " + l); } } if (!flat) { req.Layers.Add(new Evaluator.Layer { Flatten = new Evaluator.FlattenLayer { } }); } using (var call = client.EvaluateAsync(req)) { while (!call.ResponseAsync.IsCompleted) { yield return(new WaitForSeconds(0.5f)); } accuracy = call.ResponseAsync.Result.Accuracy; if (manager) { manager.SetAcurracyText(accuracy); } } }