Keras高层接口
这里所指的均为tf.keras
Keras高层API
metrics
acc_meter = metrics.Accuracy()
loss_meter = metrics.Mean()
update_state
loss_meter.update_state(loss)
acc_meter.udate_state(y, pred)
result().numpy()
print(step, 'loss:', loss_meter.result().numpy())
print(step, 'Evaluate Acc:', total_correct/total, acc_meter.result().numpy())
reset_states
if step % 100 == 0:
print(step, 'loss:', loss_meter.result().numpy())
loss_meter.reset_states()
if step % 500 == 0:
acc_meter.reset_states()
complie & fit
Compile
network.compile(optimizer=optimizers.Adam(lr=0.01),
loss=tf.loss.CategoricalCrossentropy(from_logits=True),
merics=['accuracy']</