model_reference
References to custom models.
Classes
BitfountModelReference
class BitfountModelReference( model_ref: Union[Path, str], datastructure: DataStructure, model_version: Optional[int] = None, schema: Optional[BitfountSchema] = None, username: Optional[str] = None, hub: Optional[BitfountHub] = None, hyperparameters: Optional[_StrAnyDict] = None,):
Describes a local or remote reference to a BitfountModel
class.
Arguments
model_ref
: Either path to model file or name of model on hub.datastructure
:DataStructure
to be passed to the model when initialised.model_version
: The version of the model you wish to use. Defaults to latest version.schema
:BitfountSchema
to be passed to the model when initialised.username
: The username of the model owner. Defaults to bitfount session username if not provided.hub
: Required for upload/download of model. This attribute is set after initialisation on the worker side as the hub is not serialized. Defaults to None.hyperparameters
: Hyperparameters to be passed to the model constructor after it has been loaded from file or hub. Defaults to None.
Raises
ValueError
: Ifusername
is not provided andhub
is not provided.
tip
To use another user's custom model, simply provide that user's username instead of
your own (along with the name of the model as the model_ref
argument).
Ancestors
- bitfount.models.base_models._BaseModelRegistryMixIn
- bitfount.types._BaseSerializableObjectMixIn
Methods
def get_model(self) ‑> Type[BitfountModel]:
Gets the model referenced.
If the model is a Path to a BitfountModel
, it will upload it to BitfountHub
and return the model class. If it is a name of a model on the hub, it will
download the model from the hub and return the model class.
Returns The model class.
Raises
TypeError
: If the model is not a Path or a string.TypeError
: If the model does not implementDistributedModelProtocol
.ValueError
: If aBitfountHub
instance has not been provided or if there was a communication error with the hub.
Variables
- static
fields_dict : ClassVar[Dict[str, marshmallow.fields.Field]]
- static
nested_fields : ClassVar[Dict[str, Mapping[str, Any]]]