本文整理汇总了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
)
###