src.model.deeplearn.handle.torf_transfer_handler

Classes

TORFTransferHandler(transfers)

class src.model.deeplearn.handle.torf_transfer_handler.TORFTransferHandler(transfers)
Author:

Alberto M. Esmoris Pena

The TORFTransferHandler class adapts DLTransferHandler for the TORF neural-network stage (see TransfOctoRFHandler). It follows the same JSON specification as the standard transfer learning facility:

  • model_weights: path to a .keras or .weights.h5 file carrying the source weights.

  • layer_translator: dictionary mapping target layer names to source layer names (null to skip a target layer).

  • default_to_null: whether to assume target layers absent from the translator must be skipped (true) or matched by name (false, the default).

The TORF NN architecture is built lazily inside TransfOctoRFHandler.compile(). This subclass therefore ensures that the architecture is compiled before transferring weights so the source-to-target layer matching can proceed safely.

Only this small precondition and the user-facing logging differ from the base class; the actual weight-transfer logic is fully reused.

transfer(mh)

Transfer the weights from the configured source model into the TORF neural network. Ensures the architecture is compiled before delegating to DLTransferHandler.transfer().

Parameters:

mh (TransfOctoRFHandler) – The TORF model handler whose NN must receive the transferred weights.

Returns:

Nothing at all. The TORF NN is updated in place.

static ensure_nn_built(mh)

Compile the TORF architecture if its Keras model has not been built yet. The TORF handler builds arch.nn lazily in compile(), so a transfer requested before the first fit would otherwise fail when accessing arch.nn.

Parameters:

mh (TransfOctoRFHandler) – The TORF model handler.