Processing a machine learning request

Once a machine learning request has been processed and a reply message is available, we want to consume it right away. We will know of the completion because the performing microservice will be responsible for sending a response/completion message so that others may know of the status.

Here is our ProcessMLMessage function that will handle the incoming message. Depending upon the message type, it will display the appropriate information:

bool ProcessMLMessage([NotNull] MLMessage msg, [NotNull] MessageReceivedInfo mri)
{
Console.WriteLine("Received Machine Learning Message");
RILogManager.Default?.SendInformation("Received Machine Learning Message");
switch ((MLMessageType)msg.MessageType)
{
  1. Add a LayerType type of layer to the ConvNet:
case MLMessageType.AddLayer:
RILogManager.Default?.SendInformation("Adding a layer command");
CreateLayer((LayerType)msg.LayerType, msg.param1, msg.param2, msg.param3);
PublishMessage("EvolvedAI", "", MLMessageType.Reply, LayerType.None, 0, 0,0,"Success", "", "");
break;
  1. Create the network and all the variables in it:
case MLMessageType.Create:
RILogManager.Default?.SendInformation("Create command");
CreateNetwork();
PublishMessage("EvolvedAI", "", MLMessageType.Reply, LayerType.None, 0, 0, 0, "Success", "", "");
break;
  1. Make the network start to work:
case MLMessageType.Forward:
RILogManager.Default?.SendInformation("Forward command");
ForwardPoint(msg.param1, msg.param2, msg.param3);
PublishMessage("EvolvedAI", "", MLMessageType.Reply, LayerType.None, 0, 0, 0, "Success", "", "");
break;
  1. Get the final result of the test:
case MLMessageType.GetResult:
RILogManager.Default?.SendInformation("Requesting Results");
PublishMessage("EvolvedAI", "", MLMessageType.Reply, LayerType.None, _probability, 0, 0,
"probability that x is class 0: " + _probability.Get(0), "", "");
break;
  1. Train the network:
case MLMessageType.Train:
RILogManager.Default?.SendInformation("Training the network");
TrainNetwork(msg.param1, msg.param2, msg.param3, msg.param4);
PublishMessage("EvolvedAI", "", MLMessageType.Reply, LayerType.None, 0, 0, 0, "Success", "", "");
break;
  1. Answer back:
case MLMessageType.Reply:
Console.WriteLine(msg.replyMsg1);
Console.WriteLine(msg.replyMsg2);
break;
}
return true;
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset