dacapo.experiments.starts.start

Attributes

logger

head_keys

Classes

Start

This class interfaces with the dacapo store to retrieve and load the

Functions

match_heads(model, head_weights, old_head, new_head)

Matches the head of the model to the new head by copying the weights

Module Contents

dacapo.experiments.starts.start.logger
dacapo.experiments.starts.start.head_keys = ['prediction_head.weight', 'prediction_head.bias', 'chain.1.weight', 'chain.1.bias']
dacapo.experiments.starts.start.match_heads(model, head_weights, old_head, new_head)

Matches the head of the model to the new head by copying the weights of the old head to the new head. The weights of the old head are copied to the new head by matching the labels of the old head to the labels of the new head.

Parameters:
  • model – obj The model to which the weights are to be loaded.

  • head_weights – dict The weights of the old head.

  • old_head – list The labels of the old head.

  • new_head – list The labels of the new head.

Returns:

obj

The model with the weights of the old head copied to the new head.

Return type:

model

Raises:

RuntimeError – If the old head is not found in the new head, a RuntimeError exception is thrown which is logged and handled by loading only the common layers from weights.

Examples

>>> model = match_heads(model, head_weights, old_head, new_head)

Notes

This function is called by the Start class to match the head of the model to the new head by copying the weights of the old head to the new head.

class dacapo.experiments.starts.start.Start(start_config)

This class interfaces with the dacapo store to retrieve and load the weights of the starter model used for finetuning.

run

str The specified run to retrieve weights for the model.

criterion

str The policy that was used to decide when to store the weights.

channels

int The number of channels in the input data.

__init__(start_config)

Initializes the Start class with specified config to run the initialization of weights for a model associated with a specific criterion.

initialize_weights(model, new_head=None)

Retrieves the weights from the dacapo store and load them into the model.

Notes

This class is used to retrieve and load the weights of the starter model used for finetuning from the dacapo store.

channels = None
initialize_weights(model, new_head=None)

Retrieves the weights from the dacapo store and load them into the model.

Parameters:
  • model – obj The model to which the weights are to be loaded.

  • new_head – list The labels of the new head.

Returns:

obj

The model with the weights loaded from the dacapo store.

Return type:

model

Raises:

RuntimeError – If weights of a non-existing or mismatched layer are being loaded, a RuntimeError exception is thrown which is logged and handled by loading only the common layers from weights.

Examples

>>> model = start.initialize_weights(model, new_head)

Notes

This function is called by the Start class to retrieve the weights from the dacapo store and load them into the model.