Esempio n. 1
0
        protected override string ProcessMessageAsLayerOrLoss(Command msgObj, SyftController ctrl)
        {
            switch (msgObj.functionCall)
            {
            case "prepare_to_fit":
            {
                FloatTensor input      = ctrl.floatTensorFactory.Get(int.Parse(msgObj.tensorIndexParams[0]));
                FloatTensor target     = ctrl.floatTensorFactory.Get(int.Parse(msgObj.tensorIndexParams[1]));
                Loss.Loss   criterion  = ctrl.GetLoss(int.Parse(msgObj.tensorIndexParams[2]));
                Optimizer   optim      = ctrl.GetOptimizer(int.Parse(msgObj.tensorIndexParams[3]));
                int         batch_size = int.Parse(msgObj.tensorIndexParams[4]);

                return(PrepareToFit(input, target, criterion, optim, batch_size).ToString());
            }

            case "fit":
            {
                int start_batch_id = int.Parse(msgObj.tensorIndexParams[0]);
                int end_batch_id   = int.Parse(msgObj.tensorIndexParams[1]);
                int iters          = int.Parse(msgObj.tensorIndexParams[2]);
                return(Fit(start_batch_id, end_batch_id, iters));
            }

            case "evaluate":
            {
                FloatTensor test_input  = ctrl.floatTensorFactory.Get(int.Parse(msgObj.tensorIndexParams[0]));
                FloatTensor test_target = ctrl.floatTensorFactory.Get(int.Parse(msgObj.tensorIndexParams[1]));
                Loss.Loss   criterion   = ctrl.GetLoss(int.Parse(msgObj.tensorIndexParams[2]));
                int         batch_size  = int.Parse(msgObj.tensorIndexParams[3]);
                return(Evaluate(test_input, test_target, criterion, batch_size));
            }
            }

            return(ProcessMessageAsLayerObject(msgObj, ctrl));
        }