_load_model
load_model
¶
Load saved weights for a given model.
This method can be used with TensorFlow models:
m = fe.build(fe.architecture.tensorflow.LeNet, optimizer_fn="adam")
fe.backend.save_model(m, save_dir="tmp", model_name="test")
fe.backend.load_model(m, weights_path="tmp/test.h5")
This method can be used with PyTorch models:
m = fe.build(fe.architecture.pytorch.LeNet, optimizer_fn="adam")
fe.backend.save_model(m, save_dir="tmp", model_name="test")
fe.backend.load_model(m, weights_path="tmp/test.pt")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Union[Model, Module]
|
A neural network instance to load. |
required |
weights_path
|
str
|
Path to the |
required |
load_optimizer
|
bool
|
Whether to load optimizer. If True, then it will load |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in fastestimator/fastestimator/backend/_load_model.py
preprocess_torch_weights
¶
Preprocess the torch weights dictionary.
This method is used to remove the any DataParallel artifacts in torch weigths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weights_path
|
str
|
Path to the model weights. |
required |