tools

static_params_to_dygraph(model, static_tensor_dict)[源代码]

Simple tool for convert static paramters to dygraph paramters dict.

NOTE The model must both support static graph and dygraph mode.

参数
  • model (nn.Layer) -- the model of a neural network.

  • static_tensor_dict (string) -- path of which locate the saved paramters in static mode. Usualy load by paddle.static.load_program_state.

返回

a state dict the same as the dygraph mode.

返回类型

[tensor dict]

dygraph_params_to_static(model, dygraph_tensor_dict, topo=None)[源代码]

Simple tool for convert dygraph paramters to static paramters dict.

NOTE The model must both support static graph and dygraph mode.

参数
  • model (nn.Layer) -- the model of a neural network.

  • dygraph_tensor_dict (string) -- path of which locate the saved paramters in static mode.

返回

a state dict the same as the dygraph mode.

返回类型

[tensor dict]

class TimeCostAverage[源代码]

基类:object

Simple tool for calcluating time average cost in the process of training and inferencing.

reset()[源代码]

Reset the recoder state, and reset the cnt to zero.

record(usetime)[源代码]

Recoding the time cost in current step and accumulating the cnt.

get_average()[源代码]

Returning the average time cost after the start of training.

get_env_device()[源代码]

Return the device name of running enviroment.