Search in sources :

Example 1 with TrainResultMessage

use of ml.shifu.shifu.message.TrainResultMessage in project shifu by ShifuML.

the class TrainModelWorker method handleMsg.

/* (non-Javadoc)
     * @see akka.actor.UntypedActor#onReceive(java.lang.Object)
     */
@Override
public void handleMsg(Object message) throws IOException {
    if (message instanceof TrainInstanceMessage) {
        log.info("Received train data for model training");
        TrainInstanceMessage msg = (TrainInstanceMessage) message;
        msg.getTrainer().train();
        nextActorRef.tell(new TrainResultMessage(), getSelf());
    } else {
        unhandled(message);
    }
}
Also used : TrainInstanceMessage(ml.shifu.shifu.message.TrainInstanceMessage) TrainResultMessage(ml.shifu.shifu.message.TrainResultMessage)

Example 2 with TrainResultMessage

use of ml.shifu.shifu.message.TrainResultMessage in project shifu by ShifuML.

the class TrainDtModelActor method onReceive.

/* (non-Javadoc)
     * @see akka.actor.UntypedActor#onReceive(java.lang.Object)
     */
@Override
public void onReceive(Object message) throws Exception {
    if (message instanceof AkkaActorInputMessage) {
        resultCnt = 0;
        AkkaActorInputMessage msg = (AkkaActorInputMessage) message;
        List<Scanner> scanners = msg.getScanners();
        log.debug("Num of Scanners: " + scanners.size());
        for (Scanner scanner : scanners) {
            dataLoadRef.tell(new ScanStatsRawDataMessage(scanners.size(), scanner), getSelf());
        }
    } else if (message instanceof TrainResultMessage) {
        resultCnt++;
        if (resultCnt == trainerCnt) {
            log.info("Received " + resultCnt + " finish message. Close System.");
            Encog.getInstance().shutdown();
            getContext().system().shutdown();
        }
    } else if (message instanceof ExceptionMessage) {
        // since some children actors meet some exception, shutdown the system
        ExceptionMessage msg = (ExceptionMessage) message;
        getContext().system().shutdown();
        // and wrapper the exception into Return status
        addExceptionIntoCondition(msg.getException());
    } else {
        unhandled(message);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) TrainResultMessage(ml.shifu.shifu.message.TrainResultMessage) ScanStatsRawDataMessage(ml.shifu.shifu.message.ScanStatsRawDataMessage)

Example 3 with TrainResultMessage

use of ml.shifu.shifu.message.TrainResultMessage in project shifu by ShifuML.

the class TrainModelActor method onReceive.

/* (non-Javadoc)
     * @see akka.actor.UntypedActor#onReceive(java.lang.Object)
     */
@Override
public void onReceive(Object message) throws Exception {
    if (message instanceof AkkaActorInputMessage) {
        resultCnt = 0;
        AkkaActorInputMessage msg = (AkkaActorInputMessage) message;
        List<Scanner> scanners = msg.getScanners();
        log.debug("Num of Scanners: " + scanners.size());
        for (Scanner scanner : scanners) {
            dataLoadRef.tell(new ScanTrainDataMessage(scanners.size(), isDryRun, scanner), getSelf());
        }
    } else if (message instanceof TrainResultMessage) {
        resultCnt++;
        if (resultCnt == trainerCnt) {
            log.info("Received " + resultCnt + " finish message. Close System.");
            Encog.getInstance().shutdown();
            getContext().system().shutdown();
        }
    } else if (message instanceof ExceptionMessage) {
        // since some children actors meet some exception, shutdown the system
        ExceptionMessage msg = (ExceptionMessage) message;
        getContext().system().shutdown();
        // and wrapper the exception into Return status
        addExceptionIntoCondition(msg.getException());
    } else {
        unhandled(message);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) ScanTrainDataMessage(ml.shifu.shifu.message.ScanTrainDataMessage) TrainResultMessage(ml.shifu.shifu.message.TrainResultMessage)

Aggregations

TrainResultMessage (ml.shifu.shifu.message.TrainResultMessage)3 Scanner (java.util.Scanner)2 AkkaActorInputMessage (ml.shifu.shifu.message.AkkaActorInputMessage)2 ExceptionMessage (ml.shifu.shifu.message.ExceptionMessage)2 ScanStatsRawDataMessage (ml.shifu.shifu.message.ScanStatsRawDataMessage)1 ScanTrainDataMessage (ml.shifu.shifu.message.ScanTrainDataMessage)1 TrainInstanceMessage (ml.shifu.shifu.message.TrainInstanceMessage)1