コード例 #1
0
def test(data_path="dataset/", pars_choice=0, **kwargs):
    ### Local test

    log("#### Loading params   ##############################################")
    model_pars, data_pars, compute_pars, out_pars = get_params(choice=pars_choice,
                                                               data_path=data_path, **kwargs)
    print(model_pars, data_pars, compute_pars, out_pars)

    log("#### Loading dataset   #############################################")
    dataset = get_dataset(data_pars)

    log("#### Model init, fit   #############################################")
    from mlmodels.models import module_load_full, fit, predict
    module, model = module_load_full("model_keras.01_deepctr", model_pars, data_pars, compute_pars, dataset=dataset)
    model = fit(module, model, data_pars=data_pars, compute_pars=compute_pars, out_pars=out_pars, dataset=dataset)

    # log("#### Predict   ####################################################")
    ypred = predict(module, model, compute_pars=compute_pars, data_pars=data_pars, out_pars=out_pars, dataset=dataset)

    log("#### metrics   ####################################################")
    metrics_val = metrics(ypred, dataset[1], compute_pars=compute_pars, data_pars=data_pars, out_pars=out_pars)
    print(metrics_val)

    log("#### Plot   #######################################################")

    log("#### Save/Load   ##################################################")
    save_keras(model, save_pars=out_pars)
    from deepctr.layers import custom_objects
    model2 = load_keras(out_pars, custom_pars={"custom_objects": custom_objects})
    model2.model.summary()
コード例 #2
0
ファイル: charcnn.py プロジェクト: Ruhul964/dsa2
def save(model=None,  save_pars=None, session=None):
    from mlmodels.util import save_keras
    print(save_pars)
    save_keras(model, session, save_pars=save_pars)
コード例 #3
0
ファイル: armdn.py プロジェクト: Ruhul964/dsa2
def save(model=None, session=None, save_pars={}):
    path = save_pars["outpath"]
    os.makedirs(path, exist_ok=True)
    save_keras(model, session, {"path": path + "/armdn.h5"})