示例#1
0
    tf.logging.set_verbosity(tf.logging.INFO)

    lr_params = lr_default_params()
    config = estimator_default_config()

    ds_obj = lr_params['ds_obj']
    model_dir = lr_params['model_dir']
    num_epochs = 20
    batch_size = 32
    model_params = lr_params['model_params']
    print(model_params)

    if os.path.exists(model_dir): shutil.rmtree(model_dir)  # clean model_dir
    model_fn = make_model_fn(lr_arch_fn)
    LR = tf.estimator.Estimator(model_fn=model_fn,
                                model_dir=model_dir,
                                params=model_params,
                                config=config)

    LR.train(lambda: input_fn(ds_obj.file_tr, batch_size, num_epochs, True))
    print('eval in tr dataset')
    LR.evaluate(lambda: input_fn(ds_obj.file_tr, batch_size, 1))
    print('eval in va dataset')
    LR.evaluate(lambda: input_fn(ds_obj.file_va, batch_size, 1))
    """
    eval in tr dataset
    INFO:tensorflow:Saving dict for global step 56227: accuracy = 0.78388655, auc = 0.7319471, global_step = 56227, loss = 0.4900751
    eval in va dataset
    INFO:tensorflow:Saving dict for global step 56227: accuracy = 0.7866109, auc = 0.7285157, global_step = 56227, loss = 0.48628032
    """
示例#2
0
    params = deepFM_default_params()
    config = estimator_default_config()

    ds_obj = params['ds_obj']
    model_dir = params['model_dir']
    num_epochs = 20
    batch_size = 32
    model_params = params['model_params']
    print(model_params)

    if os.path.exists(model_dir): shutil.rmtree(model_dir)  # clean model_dir
    model_fn = make_model_fn(deepFM_arch_fn)
    deepFM = tf.estimator.Estimator(model_fn=model_fn,
                                    model_dir=model_dir,
                                    params=model_params,
                                    config=config)

    deepFM.train(
        lambda: input_fn(ds_obj.file_tr, batch_size, num_epochs, True))
    print('eval in tr dataset')
    deepFM.evaluate(lambda: input_fn(ds_obj.file_tr, batch_size, 1))
    print('eval in va dataset')
    deepFM.evaluate(lambda: input_fn(ds_obj.file_va, batch_size, 1))
    """
    eval in tr dataset
    INFO:tensorflow:Saving dict for global step 56227: accuracy = 0.7947467, auc = 0.7710146, global_step = 56227, loss = 0.46117908
    eval in va dataset
    INFO:tensorflow:Saving dict for global step 56227: accuracy = 0.79159194, auc = 0.7528646, global_step = 56227, loss = 0.47020566
    """