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


Python Sequential._train方法代码示例

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


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

示例1: print

# 需要导入模块: from keras.models import Sequential [as 别名]
# 或者: from keras.models.Sequential import _train [as 别名]
"""Get functions"""
print("complie: _train")
_train = K.function(train_ins, [train_loss], updates=updates)
print("complie: _train_with_acc")
_train_with_acc = K.function(train_ins, [train_loss, train_accuracy], updates=updates)
print("complie: _predict")
_predict = K.function(predict_ins, [y_test], updates=state_updates)
print("complie: _test")
_test = K.function(test_ins, [test_loss])
print("complie: _test_with_acc")
_test_with_acc = K.function(test_ins, [test_loss, test_accuracy])

model = Sequential()
model.class_mode = "categorical"
model._train = _train
model._train_with_acc = _train_with_acc
model._predict = _predict
model._test = _test
model._test_with_acc = _test_with_acc


# Train the model each generation and show predictions against the validation dataset
for iteration in range(1, 200):
    print()
    print("-" * 50)
    print("Iteration", iteration)
    model.fit(
        D_X_train, D_y_train, batch_size=BATCH_SIZE, nb_epoch=1, validation_data=(D_X_val, D_y_val), show_accuracy=True
    )
    ###
开发者ID:lxastro,项目名称:lxnn,代码行数:32,代码来源:addition_lstm.py


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