ryanthompson591 commented on code in PR #21868:
URL: https://github.com/apache/beam/pull/21868#discussion_r898068684
##########
sdks/python/apache_beam/ml/inference/pytorch_inference.py:
##########
@@ -55,21 +55,24 @@ def _convert_to_device(examples: torch.Tensor, device) ->
torch.Tensor:
class PytorchModelHandlerTensor(ModelHandler[torch.Tensor,
PredictionResult,
torch.nn.Module]):
- """ Implementation of the ModelHandler interface for PyTorch."""
def __init__(
self,
state_dict_path: str,
model_class: Callable[..., torch.nn.Module],
model_params: Dict[str, Any],
device: str = 'CPU'):
- """
- Initializes a PytorchModelHandlerTensor
- :param state_dict_path: path to the saved dictionary of the model state.
- :param model_class: class of the Pytorch model that defines the model
- structure.
- :param device: the device on which you wish to run the model. If
- ``device = GPU`` then a GPU device will be used if it is available.
- Otherwise, it will be CPU.
+ """Implementation of the ModelHandler interface for PyTorch.
+
+ Example Usage:
+ pcol | RunInference(PytorchModelHandlerTensor(state_dict_path="my_uri"))
Review Comment:
ok will change that here and everywhere else.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]