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 1.8 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. mindspore.dataset.DSCallback
  2. =============================
  3. .. py:class:: mindspore.dataset.DSCallback(step_size=1)
  4. 用于自定义数据回调类的抽象基类。
  5. **参数:**
  6. - **step_size** (int, optional) - 调用 `ds_step_begin` 和 `ds_step_end` 之间间隔的step数(默认为1)。
  7. **样例:**
  8. >>> from mindspore.dataset import DSCallback
  9. >>>
  10. >>> class PrintInfo(DSCallback):
  11. ... def ds_epoch_end(self, ds_run_context):
  12. ... print(cb_params.cur_epoch_num)
  13. ... print(cb_params.cur_step_num)
  14. >>>
  15. >>> # dataset为任意数据集实例,op为任意数据处理算子
  16. >>> dataset = dataset.map(operations=op, callbacks=PrintInfo())
  17. .. py:method:: ds_begin(ds_run_context)
  18. 用于定义在数据处理管道启动前执行的回调方法。
  19. **参数:**
  20. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  21. .. py:method:: ds_epoch_begin(ds_run_context)
  22. 用于定义在每个数据epoch开始前执行的回调方法。
  23. **参数:**
  24. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  25. .. py:method:: ds_epoch_end(ds_run_context)
  26. 用于定义在每个数据epoch结束后执行的回调方法。
  27. **参数:**
  28. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  29. .. py:method:: ds_step_begin(ds_run_context)
  30. 用于定义在每个数据step开始前执行的回调方法。
  31. **参数:**
  32. - **ds_run_context** (RunContext) - 数据处理管道运行信息。
  33. .. py:method:: ds_step_end(ds_run_context)
  34. 用于定义在每个数据step结束后执行的回调方法。
  35. **参数:**
  36. - **ds_run_context** (RunContext) - 数据处理管道运行信息。