Keras 2 API 文档 / 回调函数 API / RemoteMonitor

RemoteMonitor

[源文件]

RemoteMonitor

tf_keras.callbacks.RemoteMonitor(
    root="http://localhost:9000",
    path="/publish/epoch/end/",
    field="data",
    headers=None,
    send_as_json=False,
)

用于将事件流式传输到服务器的回调函数。

需要安装 requests 库。默认情况下,事件会发送到 root + '/publish/epoch/end/'。调用方式是 HTTP POST,其中 data 参数是包含事件数据的 JSON 编码字典。如果 send_as_json=True,请求的内容类型将是 "application/json"。否则,序列化的 JSON 将作为表单数据发送。

参数

  • root:字符串;目标服务器的根 URL。
  • path:字符串;相对于 root 的路径,事件将发送到此路径。
  • field:字符串;数据将存储在 JSON 的哪个字段下。此字段仅在使用表单发送负载时使用(即 send_as_json 设置为 False 时)。
  • headers:字典;可选的自定义 HTTP 头。
  • send_as_json:布尔值;请求是否应以 "application/json" 格式发送。