You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.dataset.DSCallback.rst 2.1 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. mindspore.dataset.DSCallback
  2. =============================
  3. .. py:class:: mindspore.dataset.DSCallback(step_size=1)
  4. 数据处理回调类的抽象基类,用户可以基于此类实现自己的回调操作。
  5. 用户可通过 `ds_run_context` 获取数据处理管道相关信息,包括 `cur_epoch_num` (当前epoch数)、 `cur_step_num_in_epoch` (当前epoch的step数)、 `cur_step_num` (当前step数)。
  6. **参数:**
  7. - **step_size** (int, optional) - 定义相邻的 `ds_step_begin`/`ds_step_end` 调用之间相隔的step数,默认值:1,表示每个step都会调用。
  8. **样例:**
  9. >>> from mindspore.dataset import DSCallback
  10. >>>
  11. >>> class PrintInfo(DSCallback):
  12. ... def ds_epoch_end(self, ds_run_context):
  13. ... print(cb_params.cur_epoch_num)
  14. ... print(cb_params.cur_step_num)
  15. >>>
  16. >>> # dataset为任意数据集实例,op为任意数据处理算子
  17. >>> dataset = dataset.map(operations=op, callbacks=PrintInfo())
  18. .. py:method:: ds_begin(ds_run_context)
  19. 用于定义在数据处理管道启动前执行的回调方法。
  20. **参数:**
  21. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  22. .. py:method:: ds_epoch_begin(ds_run_context)
  23. 用于定义在每个数据epoch开始前执行的回调方法。
  24. **参数:**
  25. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  26. .. py:method:: ds_epoch_end(ds_run_context)
  27. 用于定义在每个数据epoch结束后执行的回调方法。
  28. **参数:**
  29. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  30. .. py:method:: ds_step_begin(ds_run_context)
  31. 用于定义在指定数据step开始前执行的回调方法。
  32. **参数:**
  33. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  34. .. py:method:: ds_step_end(ds_run_context)
  35. 用于定义在指定数据step结束后执行的回调方法。
  36. **参数:**
  37. - **ds_run_context** (RunContext) - 数据处理管道运行信息。