barrage package¶
Subpackages¶
Submodules¶
barrage.api module¶
-
class
barrage.api.
RecordLoader
(mode, **params)[source]¶ Bases:
abc.ABC
Class for loading records into DataRecord.
- Parameters
mode (
RecordMode
) – RecordMode, load mode.
-
class
barrage.api.
RecordMode
(value)[source]¶ Bases:
enum.Enum
An enumeration.
-
SCORE
= 2¶
-
TRAIN
= 0¶
-
VALIDATION
= 1¶
-
-
class
barrage.api.
RecordTransformer
(mode, loader, **params)[source]¶ Bases:
abc.ABC
Class that computes a transform on training data records & applys transform to validation and scoring data records (network input), ability to pass computed network params to the network builder, and ability to apply inverse transforms on record scores (network output).
- Parameters
mode (
RecordMode
) – RecordMode, transform mode.loader (
RecordLoader
) – RecordLoader, record loader.
-
abstract
fit
(records)[source]¶ Fit transform to records.
- Parameters
records (
List
[Dict
[str
,Any
]]) – Records, records.
-
property
network_params
¶ Special params passed to the network builder.
- Return type
dict
barrage.config module¶
barrage.console module¶
barrage.defaults module¶
barrage.engine module¶
-
class
barrage.engine.
BarrageModel
(artifact_dir)[source]¶ Bases:
object
Class for training the network and scoring records with best performing network.
- Parameters
artifact_dir – str, path to artifact directory.
-
property
artifact_dir
¶
-
predict
(records_score)[source]¶ Score records.
- Parameters
records_score (
Union
[List
[Dict
[str
,Any
]],DataFrame
]) – InputRecords, scoring records.- Return type
List
[Dict
[str
,ndarray
]]- Returns
BatchRecordScores, scored data records.
-
train
(cfg, records_train, records_validation)[source]¶ Train the network.
- Parameters
cfg (
dict
) – dict, config.records_train (
Union
[List
[Dict
[str
,Any
]],DataFrame
]) – InputRecords, training records.records_validation (
Union
[List
[Dict
[str
,Any
]],DataFrame
]) – InputRecords, validation records.
- Return type
Model
- Returns
tf.keras.Model, trained network.
barrage.log module¶
barrage.model module¶
-
barrage.model.
build_network
(cfg_model, transform_params)[source]¶ Build the network.
- Parameters
cfg_model (
dict
) – dict, model subsection of config.transform_params (
dict
) – dict, params from transformer.
- Return type
Model
- Returns
tf.keras.Model, network.
- Raises
TypeError, network not a tf.keras.Model. –
-
barrage.model.
build_objective
(cfg_model)[source]¶ Build objective (loss, loss_weights, metrics, and sample_weight_mode) for each model output.
- Parameters
cfg_model (
dict
) – dict, model subsection of config.- Return type
dict
- Returns
dict, objective
-
barrage.model.
check_output_names
(cfg_model, net)[source]¶ Check the net outputs in the config match the actual net.
- Parameters
cfg_model (
dict
) – dict, model subsection of config.net (
Model
) – tf.keras.Model, net.
- Raises
ValueError, mismatch between config and net. –
-
barrage.model.
sequential_from_config
(layers, **kwargs)[source]¶ Build a sequential model from a list of layer specifications. Supports references to network_params computed inside Transformers by specifying {{variable name}}.
- Parameters
layers (
List
[dict
]) – list[dict], layer imports.- Return type
Model
- Returns
tf.keras.Model, network.
barrage.services module¶
-
barrage.services.
create_all_services
(artifact_dir, cfg_services)[source]¶ Create all services (callbacks).
- Parameters
artifact_dir (
str
) – str, path to artifact directory.cfg_services (
dict
) – dict, services subsection of config.
- Return type
List
[Callback
]- Returns
list[Callback], all services.
-
barrage.services.
get_best_checkpoint_filepath
(artifact_dir)[source]¶ Get the filepath for the best checkpoint.
- Parameters
artifact_dir (
str
) – str, path to artifact directory.- Return type
str
- Returns
str, filepath for best checkpoint directory.
barrage.solver module¶
-
barrage.solver.
build_optimizer
(cfg_solver)[source]¶ Build the optimizer.
- Parameters
cfg_solver (
dict
) – dict, solver subsection of config.- Return type
OptimizerV2
- Returns
optimizer_v2.OptimizerV2, tf.keras v2 optimizer.
- Raises
TypeError, optimizer not an OptimizerV2. –
TypeError, learning rate is not a float or LearningRateSchedule. –