重点介绍Sequential模型方法
compile
compile(self, optimizer, loss, metrics=[], sample_weight_mode=None, **kwargs)
编译用来配置模型的学习过程,其参数有:
optimizer: str (name of optimizer) or optimizer object.
optimizer:字符串(预定义优化器名)或优化器对象,参考优化器
loss: str (name of objective function) or objective function.
loss:字符串(预定义损失函数名)或目标函数
metrics: list of metrics to be evaluated by the model.during training and testing.Typically you will use “metrics=[‘accuracy’] “.
metrics:列表,包含评估模型在训练和测试时的网络性能的指标,典型用法是metrics=[‘accuracy’]
sample_weight_mode: if you need to do timestep-wise.sample weighting (2D weights), set this to “temporal”.”None” defaults to sample-wise weights (1D).
sample_weight_mode:如果你需要按时间步为样本赋权(2D权矩阵),将该值设为“temporal”。默认为“None”,代表按样本赋权(1D权)
kwargs: for Theano backend, these are passed into K.function.
kwargs:使用TensorFlow作为后端请忽略该参数,若使用Theano作为后端,kwargs的值将会传递给 K.function
examp