Exemple #1
0
 def eval(self):
     self.learn_sharedmodel()
     model_utils.calculateFisherMatrix(self)
     model_utils.UpdateMultiTaskWeightWithAlphas(self.global_index, self.modelMain)
     self.modelMaintainMode = Model_Structure()
     model_utils.CalculateModeParametes(self)
     model_utils.CalculateModePerClassParametes(self)
     # pdb.set_trace()
     for label_test in range(self.opt.num_class):
         self.learn_sharedmodel_w(label_test)
         self.modelMain[label_test].eval()
         self.modelMain[label_test].eval_flag = True
        print("============== Train task #%d (Mean-IMM) ==============" %
              no_of_task)

        LW = model_utils.UpdateMultiTaskLwWithAlphas(L_copy[0], alpha_list,
                                                     no_of_task)
        model_utils.AddMultiTaskLayers(sess, L_copy, mlp.Layers, LW,
                                       no_of_task)
        ret = mlp.TestTasks(sess, x, y, x_, y_, debug=False)
        utils.PrintResults(alpha, ret)

        mlp.TestAllTasks(sess, x_, y_)

    ######################### Mode-IMM ##########################
    if mode_imm:
        print("")
        print("Main experiment on Drop-transfer + Mode-IMM, shuffled MNIST")
        print("============== Train task #%d (Mode-IMM) ==============" %
              no_of_task)

        LW = model_utils.UpdateMultiTaskWeightWithAlphas(
            FM, alpha_list, no_of_task)
        model_utils.AddMultiTaskLayers(sess, L_copy, mlp.Layers, LW,
                                       no_of_task)
        ret = mlp.TestTasks(sess, x, y, x_, y_, debug=False)
        utils.PrintResults(alpha, ret)

        mlp.TestAllTasks(sess, x_, y_)

    print("")
    print("Time: %.4f s" % (time.time() - start))