当前位置: 首页>>代码示例>>Python>>正文


Python utils.save_model方法代码示例

本文整理汇总了Python中utils.save_model方法的典型用法代码示例。如果您正苦于以下问题:Python utils.save_model方法的具体用法?Python utils.save_model怎么用?Python utils.save_model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils的用法示例。


在下文中一共展示了utils.save_model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: evaluate_ensemble

# 需要导入模块: import utils [as 别名]
# 或者: from utils import save_model [as 别名]
def evaluate_ensemble(train_set, test_set,
                      ensemble_params, transformer_params):
    (images_train, y_train), (images_test, y_test) = train_set, test_set

    model, accuracy, train_time, predict_time = run_pcanet_ensemble(
        ensemble_params, transformer_params,
        images_train, images_test, y_train, y_test
    )

    filename = model_filename()
    utils.save_model(model, join(pickle_dir, filename))

    params = {}
    params["ensemble-model"] = filename
    params["ensemble-accuracy"] = accuracy
    params["ensemble-train-time"] = train_time
    params["ensemble-predict-time"] = predict_time
    return params 
开发者ID:IshitaTakeshi,项目名称:PCANet,代码行数:20,代码来源:evaluation.py

示例2: evaluate_normal

# 需要导入模块: import utils [as 别名]
# 或者: from utils import save_model [as 别名]
def evaluate_normal(train_set, test_set, transformer_params):
    (images_train, y_train), (images_test, y_test) = train_set, test_set

    model, accuracy, train_time, transform_time = run_pcanet_normal(
        transformer_params,
        images_train, images_test, y_train, y_test
    )

    filename = model_filename()
    utils.save_model(model, join(pickle_dir, filename))

    params = {}
    params["normal-model"] = filename
    params["normal-accuracy"] = accuracy
    params["normal-train-time"] = train_time
    params["normal-transform-time"] = transform_time
    return params 
开发者ID:IshitaTakeshi,项目名称:PCANet,代码行数:19,代码来源:evaluation.py

示例3: nn_bow_model

# 需要导入模块: import utils [as 别名]
# 或者: from utils import save_model [as 别名]
def nn_bow_model(x_train, y_train, x_test, y_test, results, mode,
                 epochs=15, batch_size=32, hidden_units=50, save=False, plot_graph=False):
    # Build the model
    print("\nBuilding Bow NN model...")
    model = Sequential()
    model.add(Dense(hidden_units, input_shape=(x_train.shape[1],), activation='sigmoid'))
    model.add(Dense(1, activation='sigmoid'))
    model.summary()

    # Train using binary cross entropy loss, Adam implementation of Gradient Descent
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy', utils.f1_score])
    history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1)

    if plot_graph:
        utils.plot_training_statistics(history, "/plots/bow_models/bow_%s_mode" % mode)

    # Evaluate the model
    loss, acc, f1 = model.evaluate(x_test, y_test, batch_size=batch_size)
    results[mode] = [loss, acc, f1]
    classes = model.predict_classes(x_test, batch_size=batch_size)
    y_pred = [item for c in classes for item in c]
    utils.print_statistics(y_test, y_pred)
    print("%d examples predicted correctly." % np.sum(np.array(y_test) == np.array(y_pred)))
    print("%d examples predicted 1." % np.sum(1 == np.array(y_pred)))
    print("%d examples predicted 0." % np.sum(0 == np.array(y_pred)))

    if save:
        json_name = path + "/models/bow_models/json_bow_" + mode + "_mode.json"
        h5_weights_name = path + "/models/bow_models/h5_bow_" + mode + "_mode.json"
        utils.save_model(model, json_name=json_name, h5_weights_name=h5_weights_name)


# A standard DNN used as a baseline 
开发者ID:MirunaPislar,项目名称:Sarcasm-Detection,代码行数:35,代码来源:dl_models.py


注:本文中的utils.save_model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。