barrage.utils package¶
Submodules¶
barrage.utils.import_utils module¶
-
barrage.utils.import_utils.
import_loss
(import_block)[source]¶ Import a loss from an import block.
- Parameters
import_block (
dict
) – dict, {“import”: str, “params”: dict}.- Return type
Union
[Loss
,str
]- Returns
Loss/str, non-alias loss or alias.
- Raises
TypeError, non-alias loss is not a Loss. –
-
barrage.utils.import_utils.
import_metric
(import_block)[source]¶ Import a metric from an import block.
Note: A loss can be a metric, but a metric cannot always be a loss.
- Parameters
import_block (
dict
) – dict, {“import”: str, “params”: dict}.- Return type
Union
[Metric
,Loss
,str
]- Returns
Metric/Loss/str, non-alias metric or alias.
- Raises
TypeError, non-alias metric is not a Metric/loss. –
-
barrage.utils.import_utils.
import_obj_with_search_modules
(python_path, search_modules=None, search_both_cases=False)[source]¶ Import a object (variable, class, function, etc…) from a python path. search_modules are used to potentially shorten the python path by eliminating the module part of the string. Optionally check both uncapitalized and capitalized version of the object name.
- Parameters
python_path (
str
) – str, full python path or object name (in conjunction with search_modules).search_modules (
Optional
[List
[str
]]) – list[str], python modules against short path.search_both_cases – bool, try capitalized and uncapitalized object name.
- Return type
Callable
- Returns
callable, imported object.
- Raises
ImportError, object not found. –
-
barrage.utils.import_utils.
import_or_alias
(python_path)[source]¶ Import an object from a full python path or assume it is an alias for some object in TensorFlow (e.g. “categorical_crossentropy”).
- Parameters
python_path (
str
) – str, full python path or alias.- Return type
Union
[Callable
,str
]- Returns
callable/str, import object/alias.
- Raises
ImportError, object not found. –
barrage.utils.io_utils module¶
-
barrage.utils.io_utils.
load_data
(filename, path='')[source]¶ Load a file into a pandas DataFrame.
- Parameters
filename (
str
) – str.path (
str
) – str.
- Return type
DataFrame
- Returns
pd.DataFrame.
-
barrage.utils.io_utils.
load_json
(filename, path='')[source]¶ Load a json object.
- Parameters
filename (
str
) – str.path (
str
) – str.
- Returns
object.
-
barrage.utils.io_utils.
load_pickle
(filename, path='')[source]¶ Load a pickled object.
- Parameters
filename (
str
) – str.path (
str
) – str.
- Returns
object.