Executor¶
Inheritance Diagram

-
class
ashpy.losses.executor.Executor(fn=None)[source]¶ Bases:
objectCarry a function and the way of executing it. Given a context.
Methods
__init__([fn])Initialize the Executor. call(context, **kwargs)Execute the function, using the information provided by the context. reduce_loss(call_fn)Create a Decorator to reduce Losses. Attributes
fnReturn the Keras loss function to execute. global_batch_sizeGlobal batch size comprises the batch size for each cpu. weightReturn the loss weight. -
__init__(fn=None)[source]¶ Initialize the Executor.
Parameters: fn ( tf.keras.losses.Loss) – A Keras Loss to execute.Return type: NoneReturns: None
-
call(context, **kwargs)[source]¶ Execute the function, using the information provided by the context.
Parameters: context ( ashpy.contexts.Context) – The function execution Context.Return type: TensorReturns: tf.Tensor– Output Tensor.
-
fn¶ Return the Keras loss function to execute.
Return type: LossReturns: tf.keras.losses.Loss– Keras Loss.
-
global_batch_size¶ Global batch size comprises the batch size for each cpu.
Calculated as batch_size_for_replica*replica_numbers.
Return type: intReturns: int– Global Batch size value.
-
static
reduce_loss(call_fn)[source]¶ Create a Decorator to reduce Losses. Used to simplify things.
Apply a
reduce sumoperation to the loss and divide the result by the batch size.Parameters: call_fn ( typing.Callable) – The executor call method.Return type: CallableReturns: typing.Callable– The decorated function.
-
weight¶ Return the loss weight.
This weight is multiplied by the loss value. This is useful when working with multiples losses.
Return type: Callable[…,float]Returns: typing.Callable– Callable returning the weight (float).
-