sciai.utils

Util module, containing commonly used Python utils, MindSpore utils, plot utils, etc.

sciai.utils.calc_ckpt_name

Concatenate optimal checkpoint name according to existing namespace arguments.

sciai.utils.str2datatype

Map from float data type string to MindSpore data type.

sciai.utils.amp2datatype

Map from auto mixed precision level string to MindSpore data type.

sciai.utils.datatype2np

Map from MindSpore data type to numpy data type.

sciai.utils.download_resource

Download the dataset and(or) checkpoint files for model named model_name.

sciai.utils.flatten_add_dim

flatten data and add an extra dimension at the end.

sciai.utils.lazy_func

Fabricate a lazy function which can be directly called later without arguments.

sciai.utils.lazy_property

Lazy property decorator signature.

sciai.utils.log_config

Log configuration.

sciai.utils.make_sciai_dirs

Create directories for a sciai project.

sciai.utils.newfig

Plot a new figure.

sciai.utils.parse_arg

Parse arguments according to terminal/bash inputs and config dictionary.

sciai.utils.print_args

Print and log args line by line.

sciai.utils.print_log

Print in the standard output stream as well as into the log file.

sciai.utils.print_time

Print end-to-end time elapsed for a function.

sciai.utils.savefig

Save figure in both pdf and png.

sciai.utils.save_result_dir

Save figure result in given directory.

sciai.utils.set_seed

Set random seed everywhere.

sciai.utils.time_second

Get time in milliseconds number, e.g., 1678243339.780746.

sciai.utils.time_str

Get time in string representation, e.g., "2000-12-31-23-59-59".

sciai.utils.to_float

Set cell(s) to a given data type.

sciai.utils.to_tensor

Cast array(ies)/tensor(s) to a given MindSpore data type.

sciai.utils.to_tuple

Convert a given param into tuple if it's not, otherwise keep it unchanged.