Esempio n. 1
0
            pathdir = "keras_models/" + run_uuid
            model_dir = self.get_directory_path(pathdir, False)
            ktrain_cls.keras_save_model(model, model_dir)

            # Write out TensorFlow events as a run artifact
            print("Uploading TensorFlow events as a run artifact.")
            mlflow.log_artifacts(output_dir, artifact_path="events")

        print("loss function use", args.loss)


if __name__ == '__main__':
    #
    # main used for testing the functions
    #
    parser = KParseArgs()
    args = parser.parse_args()

    flag = len(sys.argv) == 1

    if flag:
        print("Using Default Baseline parameters")
    else:
        print("Using Experimental parameters")

    print("hidden_layers:", args.hidden_layers)
    print("output:", args.output)
    print("epochs:", args.epochs)
    print("loss:", args.loss)

    KTrain().train_models(args, flag)
    def build_run_args_list(self, run_data):
        a_list = []
        for p in run_data.params:
            if p.key == 'loss_function':
                a_list.append('--loss')
            else:
                a_list.append('--' + p.key)
            a_list.append(p.value)
        return a_list

if __name__ == '__main__':
    #
    # main used for testing the functions
    #
    parser = KParseArgs()
    args = parser.parse_args()

    flag = len(sys.argv) == 1

    cls = KReproduce()
    data = cls.get_run_data(args.run_uuid, args.tracking_server)
    args_list = cls.build_run_args_list(data)

    print("run_uuid:", args.run_uuid)

    args = parser.parse_args_list(args_list)

    print("hidden_layers:", args.hidden_layers)
    print("output:", args.output)
    print("epochs:", args.epochs)